Android build常见Error

  • Error: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode]
    解决方案:
    AndroidMainfest.xml 去掉 android:debuggable="true"

  • The number of method references in a .dex file cannot exceed 64K. Error
    解决方案:
    首先app的 build.gradle 中
    (1)在dependencies 中添加
    compile'com.android.support:multidex:1.0.1'
    (2)在 defaultConfig 中添加
    multiDexEnabled true
    (3)在 AndroidManifest.xml 中的 application 标签中添加

      <application  
      ...  
       android:name="android.support.multidex.MultiDexApplication"  
        ...  
     </application>  

(4)如果你的应用程序继承 Application , 那么你需要重写Application attachBaseContext方法

@Override  
 protected void attachBaseContext(Context base) {    
     super.attachBaseContext(base);     
      MultiDex.install(this) ;  
}  
  • "java.lang.OutOfMemoryError: GC overhead limit exceeded"
    在build.gradle, Andoird{}内加入
dexOptions{
               incremental false
               javaMaxHeapSize "2048M" 
               preDexLibraries = false
}
  • 在用 Unity 编译 Android 平台的应用时,遇到 Unable to list target platforms 的问题。
    Unity 在编译时会调用 Android SDK tools 中的 android 命令,而在新版本的 Android SDK tools 中,android这个命令已经废弃了,导致 Unity 无法正常编译。

从官网下载一个旧版本的 Android SDK tools 。tools_r25.2.3-windows.zip
把原来 SDK 目录下的 tools 备份一下。我是把它重命名成 tools-25.3.1 。
把下载好的旧版本的 tools 解压到 SDK 目录下。
再在 Unity 中重新编译,问题已经解决了。

找不到主题:
compile 'com.android.support:appcompat-v7:23.1.1'

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容