Android应用开发之android as gradle 使用过称中 错误处理
白羽 2018-08-10 来源 :网络 阅读 883 评论 0

摘要:本文将带你了解Android应用开发之android as gradle 使用过称中 错误处理,希望本文对大家学Android有所帮助

        本文将带你了解Android应用开发之android as  gradle 使用过称中 错误处理,希望本文对大家学Android有所帮助


 
 
1.出现以下错误
 在 gradle 中添加
Java代码  configurations.all {         resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'     }   configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'
    }
 
 2.出现 com.android.ide.common.process.ProcessException错误
 
 这个问题的出现是在将eclipse项目导入到Android Studio中,由(.9.png)图片造成的,现在的解决方法是将其换成png图片
该问题出现原因 是 你引用了 盗来的 .9.png 非正规渠道的美工图片
 
 
 
 
 
3. Error:(1, 1) 错误: 非法字符: '\ufeff'
没有看见 明显 乱码错误等
文件 内部 编码格式 ,重新 新建该类,并把内容 复制进去 ,即可解决 
 
 4. 一下 错误
Java代码  Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.  > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE      File1: I:\cache\ai-w\IteyeBlog\app\libs\httpclient-4.3.5.jar      File2: I:\cache\ai-w\IteyeBlog\app\libs\httpcore-4.3.2.jar      File3: I:\cache\ai-w\IteyeBlog\app\libs\httpmime-4.3.5.jar      File4: I:\cache\ai-w\IteyeBlog\app\libs\jackson-all-1.6.0.jar  Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
 File1: I:\cache\ai-w\IteyeBlog\app\libs\httpclient-4.3.5.jar
 File2: I:\cache\ai-w\IteyeBlog\app\libs\httpcore-4.3.2.jar
 File3: I:\cache\ai-w\IteyeBlog\app\libs\httpmime-4.3.5.jar
 File4: I:\cache\ai-w\IteyeBlog\app\libs\jackson-all-1.6.0.jar
 
解决方法
Java代码  packagingOptions {      exclude 'META-INF/DEPENDENCIES'      exclude 'META-INF/NOTICE'      exclude 'META-INF/LICENSE'      exclude 'META-INF/LICENSE.txt'      exclude 'META-INF/NOTICE.txt'  }      packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

 
 5.错误 包重复   Multiple
 
Java代码  Error:indicate that it is *not* an inner class.  Error:Execution failed for task ':app:transformClassesWithDexForDebug'.  > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/slf4j/impl/AndroidLoggerFactory;  Information:BUILD FAILED  Information:Total time: 9.049 secs  Information:89 errors  Information:0 warnings  Information:See complete output in console  Error:indicate that it is *not* an inner class.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/slf4j/impl/AndroidLoggerFactory;
Information:BUILD FAILED
Information:Total time: 9.049 secs
Information:89 errors
Information:0 warnings
Information:See complete output in console
 
 
取出多余重复报,一般在 gradle 中配置两个包没有问题,但在lib 中添加了并在gradle 中存在就会报改错误
 
 
 
 6.以下错误 
Java代码  Error:Execution failed for task ':app:transformClassesWithDexForBAIDUDebug'.  > com.android.build.api.transform.TransformException:   com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:   com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536  Error:Execution failed for task ':app:transformClassesWithDexForBAIDUDebug'.
> com.android.build.api.transform.TransformException: 
com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: 
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
 解决
Java代码  defaultConfig {      ...   multiDexEnabled true   ...   }      com.android.support:multidex:1.0.0  defaultConfig { 
   ... 
multiDexEnabled true 
... 
}


com.android.support:multidex:1.0.0
 
 7. multidex NoClassDefFoundError 问题
 
Java代码  public class MyApplication extends  Application {         public static MyApplication myApplication;                   public static MyApplication newInstance() {          return myApplication;      }      @Override      public void onCreate() {          super.onCreate();          myApplication = this;      }        @Override      protected void attachBaseContext(Context base) {          super.attachBaseContext(base);          MultiDex.install(this);      }  }          android {      compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)      buildToolsVersion BUILD_TOOLS_VERSION      defaultConfig {          applicationId "com.curiousby.baoyou.cn.iteyeblog"          minSdkVersion SAMPLE_MIN_SDK_VERSION          targetSdkVersion SAMPLE_TARGET_SDK_VERSION          versionCode 3          versionName "3.0"          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"          multiDexEnabled true      }    }           compile 'com.android.support:multidex:1.0.1'  public class MyApplication extends  Application {
 
    public static MyApplication myApplication; 
    
    
    public static MyApplication newInstance() {
        return myApplication;
    }
    @Override
    public void onCreate() {
        super.onCreate();
        myApplication = this;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}




android {
    compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
    buildToolsVersion BUILD_TOOLS_VERSION
    defaultConfig {
        applicationId "com.curiousby.baoyou.cn.iteyeblog"
        minSdkVersion SAMPLE_MIN_SDK_VERSION
        targetSdkVersion SAMPLE_TARGET_SDK_VERSION
        versionCode 3
        versionName "3.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

}




 compile 'com.android.support:multidex:1.0.1'
  
 
 
 
 
     

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Android频道!

本文由 @白羽 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程