我构建了一个应用程序,并且有不同的类,首先当我尝试运行该应用程序时出现这样的错误
无法在单个 dex 文件中容纳请求的类(#methods:66087 > 65536)
我遵循了 Google 的一些说明,并将其添加到了我的 build.gradle 中
这种依赖
实现 'com.android.support:multidex:1.0.3'
和默认配置这个
multiDexEnabled true
在我的清单 xml 中我添加了这个
Run Code Online (Sandbox Code Playgroud)android:name="android.support.multidex.MultiDexApplication"
但它以红色突出显示,当我将光标移到它上面时,它会显示
未解析的 MultiDexApplication 类
当我尝试再次运行该应用程序时,它抛出了我
没有已知文件:classes2.dex
已知地图:{RelativeFile{base=/Users/***/AndroidStudioProjects/****/app/build/intermediates/dex/debug/mergeDexDebug/out/classes.dex, path=classes.dex, type=DIRECTORY} =classes.dex,RelativeFile{base=/Users/****/AndroidStudioProjects/****/app/build/intermediates/dex/debug/mergeProjectDexDebug/out/classes.dex,路径=classes.dex,类型=目录}=classes3.dex,RelativeFile{base=/Users/*****/AndroidStudioProjects/****/app/build/intermediates/dex/debug/mergeExtDexDebug/out/classes2.dex,path=classes2.dex ,类型=目录}=classes4.dex}
这是 MainActivity 类
package com.example.drivieapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Intent i = new Intent(this, screenNotLogged.class );
Thread timer = new Thread() {
public void run() {
try {
sleep(3100);
}
catch(InterruptedException e) {
e.printStackTrace();
}
finally {
startActivity(i);
finish();
}
}
};
timer.start();
}
}
Run Code Online (Sandbox Code Playgroud)
你能解释一下我必须做什么吗?我用谷歌搜索了解决方案,但不太明白。非常感谢!
清单 XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="****">
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Drivie"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>
<activity android:name=".SignupCarrier"></activity>
<activity android:name=".carrierSignupHint" />
<activity android:name=".home" />
<activity android:name=".SignupSender" />
<activity android:name=".signup" />
<activity android:name=".screenNotLogged" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)