2017-03-08 43 views
0

重命名包后,我的项目在android中生成时显示错误。重命名包后,我的项目显示错误,同时在android中构建

我用这个:Android Studio Rename Package重命名我的项目之后,它开始收到这些错误:

Error:The number of method references in a .dex file cannot exceed 64K. 
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html 

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException 

然后我用https://developer.android.com/tools/building/multidex.html 解决第一个错误,但也没有工作。

因此,我重新启动Android Studio,然后再次尝试构建但出现相同的错误。

然后我试图撤消回老包的名字,但没有很好的事..... 请帮助!...提前

感谢......

+0

能够在您的应用程序multidex级别的gradle文件 –

+0

你可以添加你已经完成的变化来解决'multidex'错误 – Sanjeet

+0

通过这个链接它会解决你的问题http://stackoverflow.com/ a/36786721/7604342 –

回答

0

dependencies {//just add below one in dependency 
compile 'com.android.support:multidex:1.0.0' ....//no change your old jar file.....} 

然后

android { 
compileSdkVersion 24 
buildToolsVersion '24.0.1' 
defaultConfig { 
    applicationId "your pkg name" 
    minSdkVersion 15 
    targetSdkVersion 24 
    versionCode 6 
    versionName "v2.5.2.2" 
    multiDexEnabled true // just add it 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
productFlavors { 
} 
dexOptions { //add it 
    javaMaxHeapSize "4g" 
}} 

清单文件首先添加下面的代码的build.gradle

<application 
android:name=".Education_multidex" //add what ur create java file 
android:allowBackup="true" 
android:icon="@drawable/rvms_education_luncher" 
android:label="@string/app_name" 
android:supportsRtl="true" 
android:theme="@style/AppTheme"> ....</application> 

然后创建并添加一个Java文件一样Education_multidex.java

public class Education_multidex extends MultiDexApplication {/* @Override 
protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
}*/} 

finaly建立自己的应用程序,然后添加一些进口的lib在上面的Java文件

0

可以请你只需添加下面的代码在你的build.gradle

android { 

    defaultConfig { 
     ... 

     // Enabling multidex support. 
     multiDexEnabled true 
    } 
    ... 
} 

dependencies { 
    compile 'com.android.support:multidex:1.0.0' 
} 

,并在您ApplicationClass添加下面的代码。

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

我觉得还有一种方法可以提高dexing操作的堆栈限制。在build.gradle文件添加到您的android关闭:

dexOptions { 
    javaMaxHeapSize "4g" 
} 
+0

现在,它给出错误:'错误:意外的顶级错误: 错误:java.lang.OutOfMemoryError:超出GC开销限制 错误:任务':app:transformClassesWithDexForDebug'的执行失败。 > com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:java.lang。UnsupportedOperationException' –

+0

这也花了很长时间来建立:'信息:总时间:5分钟41.435秒' –

+0

@AbhilashMaurya:请你检查我的更新答案。 –

相关问题