我正在尝试使用新的Android Studio测试Google Play服务.我有一个与google_play_services.jar相关的项目.但是当我尝试重建项目时,我收到以下错误:
Information:[TstGP3-TstGP3] Crunching PNG Files in source dir: C:\Users\ans\AndroidStudioProjects\TstGP3\TstGP3\src\main\res
Information:[TstGP3-TstGP3] To destination dir: C:\Users\ans\AndroidStudioProjects\TstGP3\build\classes\res-cache\TstGP3-TstGP3
Information:Compilation completed with 2 errors and 0 warnings in 2 sec
Information:2 errors
Information:0 warnings
C:\Users\ans\.AndroidStudioPreview\system\compiler\tstgp3.3f17bd41\.generated\Android_BuildConfig_Generator\TstGP3-TstGP3.74fc5b25\production\com\example\tstgp3\BuildConfig.java
Error:Error:line (4)error: duplicate class: com.example.tstgp3.BuildConfig
C:\Users\ans\.AndroidStudioPreview\system\compiler\tstgp3.3f17bd41\.generated\aapt\TstGP3-TstGP3.74fc5b25\production\com\example\tstgp3\R.java
Error:Error:line (10)error: duplicate class: com.example.tstgp3.R
Run Code Online (Sandbox Code Playgroud)
它似乎有两个BuildConfig文件和两个R类.我该如何解决这个问题?
编辑:
我注意到编译器编译了两个R.java文件:一个位于我的项目文件夹中,另一个位于文件夹%USERPROFILE%.AndroidStudioPreview所以,我试图在编译器设置中排除这个"Preview"文件夹现在它正在发挥作用.只有在我的项目中开始使用Google Play服务类后,才会出现此问题.如果有人能解释这个问题背后的原因,我将不胜感激.
在收购Android-Studio之后,我现在的项目一直在用Gradle构建,因为我创建它(大约一个月前).[我在Android-Studio上安装了一些早期更新,并且对这些更新没有任何问题.]
但是,今天,在我将Android-Studio的最新更新升级到"7月11日"版本后,从版本0.1.9升级到0.2.0,我的项目开始抱怨Gradle现在需要至少达到0.5.0.(我的项目是要求Gradle 0.4,这个新的Studio升级标记了我的Gradle构建并声明它现在需要这个新的更高的Gradle最小值.
所以,我不清楚的是:我一直认为Gradle是Android Studio的一部分(捆绑).
我现在需要更新的Gradle作为单独的产品/更新吗?
我糊涂了!!!
编辑:(这发生在Windows-7下).
我运行或调试应用程序时遇到此错误,但是当我构建或清理项目时没有错误.这听起来很奇怪,但我浪费了4-5个小时来寻找这个,但没有任何帮助.错误:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.> java.io.FileNotFoundException: C:\Users\Saeed Jassani\Downloads\AppName\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\8.4.0\jars\classes.jar (The system cannot find the path specified)
Run Code Online (Sandbox Code Playgroud)
build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
}
Run Code Online (Sandbox Code Playgroud) 我一直在使用Android Studio在我的MacBook pro中开发我的项目.我将我的项目存储在GitHub仓库中.但现在我正在使用Windows笔记本电脑,所以我克隆了我的项目并尝试在Android Studio中运行,我收到以下错误:
Error:failed to find Build Tools revision 23.0.0 rc2
Install Build Tools 23.0.0 rc2 and sync project
Run Code Online (Sandbox Code Playgroud)
我点击了
Install Build Tools 23.0.0 rc2 and sync project” but I’m getting another error:
Loading SDK information...
Run Code Online (Sandbox Code Playgroud)
忽略未知的包过滤器'build-tools-23.0.0-preview'警告:包过滤器删除了所有包.没有什么可以安装的.请考虑在没有包过滤器的情况下再次尝试更新.
安装失败.请检查您的网络连接,然后重试.您可以继续创建项目,但如果没有缺少的组件,它将无法正确编译.(我已经检查了我的网络连接,我使用有线连接连接到互联网).
当我在Macbook中克隆我的项目时,一切正常,所以我不确定为什么它不适用于Windows.
更新并重新启动android studio后,我收到以下错误.
错误:任务':app:compileDebugJavaWithJavac'的执行失败.java.io.FileNotFoundException:/.../Workspace/MyAppName/app/build/intermediates/exploded-aar/com.google.android.gms/play-services/8.3.0/jars/classes.jar(没有这样的文件或目录)
我已经尝试清理并重建我的项目,但每次我都遇到上述错误.
EDITS:
我的gradle如下:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
Run Code Online (Sandbox Code Playgroud)