我使用我自己的Android库在Kotlin上完成。 我将该库构建到* .aar文件中,并在React Native的单独项目中导入。 崩溃出现在Android React Native应用程序中,当我从该库启动Service时,其中一些字段以懒惰方式初始化。 我找不到类似“Lkotlin / LazyKt”或“kotlin.LazyKt”的错误。 也许有人遇到类似的问题? 我会很感激任何提示。 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.project_mobile:sdmp, PID: 18913 java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/LazyKt; at com.project.service.SdmService.(SdmService.kt:27) at java.lang.Class.newInstance(Native Method) at android.app.ActivityThread.handleCreateService(ActivityThread.java:2859) at android.app.ActivityThread.-wrap4(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.ClassNotFoundException: Didn’t find class […]
我尝试通过“gradlew connectedAndroidTest”运行一个仪器测试。 我得到以下错误: Tests on GT-I9305 – 4.3 failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException' com.android.builder.testing.ConnectedDevice > hasTests[GT-I9305 – 4.3] FAILED No tests found. :mobile:connectedAndroidTest FAILED 这是带有–stacktrace选项的输出: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':mobile:connectedAndroidTest'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) […]
最近,当我用Windows 8.1在家里完成自己的工作时,发现项目无法正常工作 – 编译,在模拟器上运行,并在某个特定点崩溃(100%可重现在我的电脑上)。 但是,同样的版本库修订版可以在工作的Mac上以及同事的Windows 10机器上运行。 每个提到的环境都使用Android Studio 2.3.1,gradle 3.3和Kotlin 1.1.1,并在API 25 x86_64映像上运行应用程序。 该项目正在使用multidex 1.0.1库。 由于以下例外,发生崩溃: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.project.app, PID: 2533 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/project/package/SomeActivityKt$sam$Action1$22181393; at com.project.package.SomeActivity.getDataFor(SomeActivity.kt:164) at com.project.package.SomeActivity.getData(SomeActivity.kt:147) at com.project.package.SomeActivity.onResume(SomeActivity.kt:142) at android.app.Instrumentatcomn.callActivityOnResume(Instrumentatcomn.java:1269) at android.app.Activity.performResume(Activity.java:6783) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) […]
package com.example.manish.myapplication import android.support.v7.app.AppCompatActivity import android.os.Bundle class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } } fun main(arg : Array<String>){ print("HI") } logcat的: Exception in thread "main" java.lang.ClassNotFoundException: com.example.manish.myapplication.MainActivityKt at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:107)
我想给Kotlin一个尝试,所以我决定尝试将我的项目的单个类转换为Kotlin,并在尝试转换整个项目之前查看它如何与我的工作流程集成。 我能够构建和我的应用程序正常工作,但在第一个后,每一个后续的构建,我从ClassLoader下面的异常。 该应用程序只能清理后正常工作,并在我转换任何东西之前工作正常。 我可以在同一台机器上多次运行HelloWorld项目,而不会出错。 在这个问题中的回应没有帮助: 在使用kotlin的自定义风格的ClassNotFoundException 07-31 14:35:41.563 1878-1878/com.ddiehl.android.htn.debug E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.ddiehl.android.htn.debug, PID: 1878 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ddiehl.android.htn.debug/com.ddiehl.android.htn.view.activities.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ddiehl.android.htn.view.activities.MainActivity" on path: DexPathList[[zip file "/data/app/com.ddiehl.android.htn.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ddiehl.android.htn.debug-1/lib/arm, /vendor/lib, /system/lib]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at […]
在我的Android Studio 2.3.3中,我安装了Kotlin插件,然后创建了一个kotlin类的活动。 当我完成并运行该活动时,我得到了ClassNotFoundException。 我确认我已经在清单文件中添加了新的Activity。 我第一次尝试与Android的Kotlin,并不确定是否需要更改Gradle文件或不使用Kotlin。 以下是我的错误日志: FATAL EXCEPTION: main Process: com.example.chandan.myapplication, PID: 16035 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.chandan.myapplication/com.example.chandan.myapplication.RegistrationActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.chandan.myapplication.RegistrationActivity" on path: DexPathList[[zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/base.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.chandan.myapplication-xkv2k_8ODBWxxa3Gsn-HDw==/split_lib_slice_6_apk.apk", zip […]
Intent intent=new Intent(MainActivity.this, ContactListActivity.class); startActivity(intent); MainActivity.this是用java编写的,ContactListActivity是用kotlin编写的。 我想调用ContactListActivty,但最终得到错误 have you declared this activity in your AndroidManifest.xml? 我还在清单文件中添加了该活动。 <activity android:name="Chat_Activity$Connections$ContactListActivity" android:parentActivityName=".MainActivity"> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity"/> </activity> 编辑: ContactListActivity.kt class ContactListActivity : AppCompatActivity() { private var mBroadcastReceiver: BroadcastReceiver? = null private val TAG:String="ContactListActivity" //static variable object Obz{ @JvmStatic val GetContactListFromServer:String="Contact List" } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(layout.activity_contact_list) […]
我试着开始将基于Java的multidexed项目迁移到Kotlin,但是每当应用程序尝试引用Kotlin类时,我都会得到ClassNotFoundException。 奇怪的是,有时相同的代码有时不工作。 有计算机产生工作apk和其他人没有。 有时候重建就足以解决问题。 我试图谷歌它,但我只找到这个线程,但没有解决方案。 这个东西是否适用于其他人或者没有任何multidexed Kotlin项目呢? 我已经尝试了AS 2.3.3和AS 3.0.0-beta6,2.3.3 android插件,kotoin版本1.1.50, 没有proguard 。 buildscript { ext.kotlin_version = '1.1.50' ext.android_plugin_version = '2.3.3' ext.support_lib_version = '25.3.1' ext.play_services_version = '11.0.4' repositories { jcenter() maven { url "https://maven.google.com" } } dependencies { classpath "com.android.tools.build:gradle:$android_plugin_version" classpath 'me.tatarka:gradle-retrolambda:3.2.5' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:3.0.0' classpath 'com.google.firebase:firebase-plugins:1.1.1' } } allprojects { repositories { jcenter() […]