GenericSettings icon indicating copy to clipboard operation
GenericSettings copied to clipboard

exception when opening activity

Open or-dvir opened this issue 7 years ago • 4 comments

hi. i get an error when i try to open my settings activity.

here is the exception:

FATAL EXCEPTION: main
                                                                                   Process: com.ictseurope.genericsettings_test, PID: 4898
                                                                                   java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
                                                                                       at com.oshi.libgenericsettings.adapter.SettingsAdapter.<init>(SettingsAdapter.kt)
                                                                                       at com.ictseurope.genericsettings_test.settingsActivity.onCreate(settingsActivity.java:18)
                                                                                       at android.app.Activity.performCreate(Activity.java:6272)
                                                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
                                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
                                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
                                                                                       at android.app.ActivityThread.access$900(ActivityThread.java:157)
                                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                       at android.os.Looper.loop(Looper.java:148)
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:5551)
                                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
                                                                                    Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.ictseurope.genericsettings_test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ictseurope.genericsettings_test-1/lib/arm64, /vendor/lib64, /system/lib64]]
                                                                                       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 com.oshi.libgenericsettings.adapter.SettingsAdapter.<init>(SettingsAdapter.kt) 
                                                                                       at com.ictseurope.genericsettings_test.settingsActivity.onCreate(settingsActivity.java:18) 
                                                                                       at android.app.Activity.performCreate(Activity.java:6272) 
                                                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
                                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387) 
                                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) 
                                                                                       at android.app.ActivityThread.access$900(ActivityThread.java:157) 
                                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356) 
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                       at android.os.Looper.loop(Looper.java:148) 
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:5551) 
                                                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
                                                                                   	Suppressed: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
                                                                                       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)
                                                                                       		... 15 more
                                                                                    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

here is my code:

public class settingsActivity extends AppCompatActivity
{
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_settings);

		RecyclerView recycler = findViewById(R.id.recyclerView);
		SettingsAdapter adapter = new SettingsAdapter(this, new MyPresenter());
		recycler.setAdapter(adapter);
	}
}
public class MyPresenter extends BaseSettingsPresenter
{
	@NonNull
	@Override
	public List<BaseViewTypeData> getItems(Context context)
	{
		List<BaseViewTypeData> items = new ArrayList<>();

		ArrayList<String> subitems = new ArrayList<>();
		subitems.add("import");
		subitems.add("export");
		ExpandableTitleSubtitleSimpleItemsData importExport =
				new ExpandableTitleSubtitleSimpleItemsData("import/export",
														   "export your shows to an external file or import shows to this device from an existing file",
														   subitems);

		items.add(importExport);

		return items;
	}

	@Override
	public void onExpandableSimpleItemClicked(@NonNull View view,
											  @NonNull ExpandableTitleSimpleItemsData data,
											  int parentPosition,
											  int subItemPosition)
	{
		super.onExpandableSimpleItemClicked(view, data, parentPosition, subItemPosition);

		Toast.makeText(view.getContext(),
					   data.getItems().get(subItemPosition) + " Selected",
					   Toast.LENGTH_SHORT)
			 .show();
	}
}

never used kotlin... do i have to enable it in my project in order to use this library or something? if so, please provide instructions as i have never used kotling (also would be nice if you could update the README)

or-dvir avatar Feb 20 '18 10:02 or-dvir

Investigating issue. Will be back shortly with an answer

UdiOshi85 avatar Feb 20 '18 11:02 UdiOshi85

Hi Or, Issue is still under check. Seems like a major issue (So thanks for that). As this library is written in Kotlin, you will have to enable it in you app also (Adding Kotlin to your app build.gradle and the kotlin plugin in project build.gradle) Once I will fix everything I will update the README file and you as well.

UdiOshi85 avatar Feb 23 '18 15:02 UdiOshi85

i dont understand, will adding kotlin to the my app fix the problem? when you say "once i will fix everything" you mean to make it work even if my app does not have kotlin?

or-dvir avatar Feb 23 '18 19:02 or-dvir

Yesterday I did a quick example (fresh project and compile the library) and came to 2 conclusions:

  1. You must enable Kotlin in your app
  2. You must add constraint layout library also (adding implementation 'com.android.support.constraint:constraint-layout:1.0.2' to app build.gradle dependencies)

And it will work just fine.

The constraint layout thing is something that bothers me and im still checking it out.

So basically all you need to do is the following:

Project build.gradle file:

    buildscript {
        repositories {
        google()
        jcenter()
    }
    dependencies {
        ...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.21"
    }
} 

App module build.gradle file

dependencies {
    ...
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.21"
    implementation "com.github.udioshi85:libGenericSettings:1.4.1"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    ...
}

UdiOshi85 avatar Feb 23 '18 21:02 UdiOshi85