내 응용 프로그램이 잘 작동하는 경우 내에서 테스트를 사용하여 실제 장치가 USB 안드로이드 스튜디오에.그러나 때 나는 경우 다른 장치로 설치가있다,그것은 작동하지 않습니다.응용 프로그램 추락했다.내가 찾지 못했른 방법으로 문제를 해결합니다.오류는 아래와 같습니다:
FATAL EXCEPTION: main Process: com.w3xplorers.cmch,PID: 17715 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.w3xplorers.cmch/com.w3xplorers.cmch.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.w3xplorers.cmch.MainActivity" on path: DexPathList[[zip file "/data/app/com.w3xplorers.cmch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.w3xplorers.cmch-1/lib/arm, /system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.w3xplorers.cmch.MainActivity" on path: DexPathList[[zip file "/data/app/com.w3xplorers.cmch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.w3xplorers.cmch-1/lib/arm, /system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1085)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) Suppressed: java.lang.ClassNotFoundException: com.w3xplorers.cmch.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
나의 명단은 다음과 같습니다.
`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.w3xplorers.cmch">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:name="com.w3xplorers.cmch.EnableMultiDex"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name="com.w3xplorers.cmch.MainActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.w3xplorers.cmch.HomeActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.w3xplorers.cmch.QuickSms"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.w3xplorers.cmch.GroupSms"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.w3xplorers.cmch.SelfSms"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.w3xplorers.cmch.Contact"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.w3xplorers.cmch.Favourite"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.w3xplorers.cmch.Info"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name="com.w3xplorers.cmch.Dialog" />
</application>
</manifest>`
Gradle below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.w3xplorers.cmch"
minSdkVersion 13
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5'
compile 'com.android.support:design:25.3.0'
compile 'com.andreabaccega:android-form-edittext:1.0.3'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
에서의 응용 프로그램,태그를 변경
android:name="com.w3xplorers.cmch.EnableMultiDex"
가
android:name="android.support.multidex.MultiDexApplication"
도움이 되기를 바랍:)
더 많은 정보:
을 따라하는 공식 문서: https://developer.android.com/studio/build/multidex.html#mdex-gradle
니다.gradle:
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
YourApp 클래스
public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
나는 자바를 사용 8 을 지원한 후 업데이트 안드로이드 스튜디오 3.5
다음 줄을 추가에서 빌드.gradle file:
android {
defaultConfig {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
할 수 있는 설명서를 확인하기: https://developer.android.com/studio/write/java8-support
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
어쩌면 당신은 don't 응용 프로그램을 만들 Multidex.설치(this);
를 실행하는 사람들로 이를 사용하여 코 틀린을 위해 자신의 계측 테스트:
*을 유지 하는 마음에 공백을 메서드 이름이만 작동에 대한 JVM 을 테스트하지안드로이드 계측 시험**(로 주목에 의해 제이크 와튼]1,그는 또한이 해결할 수 있습니다 미래에)
순간에 빠르게 액세스할 수 있습니를 실행하는 테스트는 다음과 같:
@Test
fun `spaces should work in names`() {
}
테스트는 출력을 말합니다:
No 테스트를 발견되었다
와 로그를 말한다:
실행하기 시작했 테스트
테스트 실행하지 못했습니다:계측기는 실행이 실패로 인해'프로세스 충돌했습니다.'
빈 테스트습니다.
동환 출력이 예외:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example, PID: 5424
java.lang.RuntimeException: Unable to instantiate instrumentation
ComponentInfo{com.example.test/android.support.test.runner.AndroidJUnitRunner}:
java.lang.ClassNotFoundException: Didn't find class
"android.support.test.runner.AndroidJUnitRunner"
on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5730)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"android.support.test.runner.AndroidJUnitRunner" on path:
DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5728)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
당신이 볼 수있는,오는데 많은 도움이 되지 않는다,그래서 나는 여기에서 희망하는 사람들이 지금 대답. 해결책은 간단하다,사용하는 유효한 같은 이름:
@Test
fun spaces_dontWorkInNames() {
}
변 확장 클래스의를 클래스는 응용 프로그램
에서공급다.장 응용 프로그램{...}
하는공공급다.장 MultiDexApplication{...}
에 대한 자세한 설명에 따라 공식 문서:https://developer.android.com/studio/build/multidex.html#mdex-gradle
그것은 나를 위해 일