将Eclipse项目导入Android Studio遇到的各种坑

2016-11-16 liuyingcong 安卓开发


1、报错:Execution failed for task ':app:compileDebugJava'. Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

   弯路:可是明明配置了环境变量,cmd中运行java -version和javac -version都是1.7;安装jdk1.8没解决问题;

   答案:android-studio 中 File->Other Settings->Default Project Structure->SDK Location 取消勾选Use embedded JDK,输入jdk路径即可

2、报错:Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in C:\gaoyuan\code\workspace-android\Elight\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip.

    报错:Error:(1, 1) A problem occurred evaluating root project 'TingPhoneSDKTest'.
> Failed to apply plugin [id 'com.android.application']
   > Minimum supported Gradle version is 2.14.1. Current version is 2.12. If using the gradle wrapper, try editing the distributionUrl in E:\code\Case\TingPhoneSDKTest\gradle\wrapper\gradle-wrapper.properties to gradle-2.14.1-all.zip

     答案:File->Setting->Gradle  Project-level settings    勾选Use default gradle wrapper(recommended)

3、Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

   答案:将项目中 build.gradle中android{compileSdkVersion 23与dependencies{compil'com.android.support:appcompat-v7:25.0.1'相匹配,即都用最新的Android平台版本。

4、 运行时报错:Unsupported method: AndroidProject.getPluginGeneration().

The version of Gradle you connect to does not support that method.

To resolve the problem you can change/upgrade the target version of Gradle you connect to.

Alternatively, you can ignore this exception and read other information from the model.

   答案:File -> Settings -> Build, Execution, Deployment -> Instant Run.

        Enable

        Instant Run to hot swap code...

5、 报错:Error:Error converting bytecode to dex:

Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

    答案:出现以上问题一般是jar包冲突,删除掉相同的jar.如v7包中的v4包

6、 报错:Error:(1, 0) Plugin with id 'com.android.application' not found.

7、 报错:Error:(1, 0) Your project path contains non-ASCII characters...

     答案:因为项目所在路径中含有非ASCII码字符(如汉字)。关闭项目,将汉字改为英文,重新打开即可。

8、 报错:Error:(1, 1) A problem occurred evaluating root project 'TingPhoneSDKTest'.

> Failed to apply plugin [id 'com.android.application']
   > Minimum supported Gradle version is 2.14.1. Current version is 2.12. If using the gradle wrapper, try editing the distributionUrl in E:\code\Case\TingPhoneSDKTest\gradle\wrapper\gradle-wrapper.properties to gradle-2.14.1-all.zip

     答案:Project Structure -> Project -> Gradle version 的2.12改为2.14.1 。 




网站备案号:京ICP备11043289号-1 北京市公安局网络备案 海1101084571
版权所有 北京育灵童科技发展有限公司 Copyright © 2002-2024 www.elight.cn, All Rights Reserved