build.gradle
应用插件:“ com.android.application”
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.appium_new"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
packagingOptions {
exclude 'lang-708-input.txt'
exclude 'java.policy'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
依赖性{
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('src/libs/byte-buddy-1.8.15.jar')
implementation files('src/libs/commons-exec-1.3.jar')
implementation files('src/libs/commons-lang3-3.9.jar')
implementation files('src/libs/commons-lang3-3.9-sources.jar')
implementation files('src/libs/commons-lang3-3.9-test-sources.jar')
implementation files('src/libs/commons-lang3-3.9-tests.jar')
implementation files('src/libs/guava-25.0-jre.jar')
implementation files('src/libs/java-client-7.3.0.jar')
implementation files('src/libs/okhttp-3.11.0.jar')
implementation files('src/libs/okio-1.14.0.jar')
implementation files('src/libs/selenium-server-standalone-3.141.59.jar')
}
添加了最后一个库即实现文件('src / libs / selenium-server-standalone-3.141.59.jar')后,显示以下错误,如果我删除了该库,则可以正常工作
2019-11-13 18:05:44.994 12737-12744 /? E / com.appium_new:无法将DDMS数据包REAQ发送到调试器(-1 / 20):管道损坏
2019-11-13 18:05:45.587 12737-12737 /? E / AndroidRuntime:致命异常:main 流程:com.appium_new,PID:12737
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appium_new/com.appium_new.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.appium_new.MainActivity" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/lib/x86, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2843)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.appium_new.MainActivity" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 15 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 18 more
答案 0 :(得分:0)
添加库gradle后未正确同步,因此显示错误“找不到类'.MainActivity'”:
主要问题是某些gradle文件具有相同的内部文件,例如:-
NULL
或
WHERE (a.Checkdate >= b.ValidFrom OR b.ValidFrom IS NULL)
AND (a.CheckDate < b.ValidTill OR B.ValidTill IS NULL)
因此无法成功同步,
或者第二种选择是使用gradle版本,例如
implementation files('src/libs/okhttp-3.11.0.jar')
implementation files('src/libs/okio-1.14.0.jar')
并根据您的需要放置版本...
主要问题是ClassNotFoundException,因此请检查此link给出了许多解决方案。使用它,看看您的项目有什么用。