Search code examples
androidandroid-ndknativesfml

java.lang.ClassNotFoundException: Didn't find class … on path: DexPathList


I'm trying to build SFML app for android, but getting some strange errors. First, my app configured like that:

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := sfml-example

LOCAL_SRC_FILES := main.cpp

LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_SHARED_LIBRARIES += sfml-activity
LOCAL_SHARED_LIBRARIES += openal
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main

include $(BUILD_SHARED_LIBRARY)

$(call import-module,third_party/sfml)

Application.mk

NDK_TOOLCHAIN_VERSION := 4.9
APP_PLATFORM := android-19
APP_STL := c++_static
APP_ABI := all
APP_MODULES := sfml-activity sfml-example
APP_OPTIM := release
APP_CFLAG := -g -O3

It's compiled and work fine on Android 5,6,7. But when I tried to launch app on android 6.0 I got an error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.sfml_test.android/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/org.sfmldev.android-1/lib/arm/libsfml-activity.so

I found similar problem in this question. So I tried to write activity, which should load SFML lib. Activity code:

package org.sfmldev.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;


public class SFMLLoader  extends Activity {
    static {
        System.loadLibrary("sfml-activity");
        System.loadLibrary("sfml-example");
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(SFMLLoader.this, android.app.NativeActivity.class);
        SFMLLoader.this.startActivity(intent);
    }
}

And i change my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="org.sfmldev.android">

    <uses-feature android:glEsVersion="0x00010001" />

    <uses-permission android:name="android.permission.VIBRATE" />


    <application android:label="@string/app_name"
                 android:icon="@drawable/sfml_logo"
                 android:hasCode="false"
                 android:allowBackup="false"
                 android:testOnly="false"
        tools:ignore="GoogleAppIndexingWarning">

        <activity android:name="org.sfmldev.android.SFMLLoader"
            android:label="@string/app_name"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="android.app.NativeActivity"
              android:label="@string/app_name"
              android:icon="@drawable/sfml_logo"
              android:configChanges="keyboardHidden|orientation|screenSize">

        <meta-data android:name="android.app.lib_name" android:value="sfml-activity" />
        <meta-data android:name="sfml.app.lib_name" android:value="sfml-example" />

    </activity>
    </application>
</manifest>

And now I have new error on any devices:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.sfmldev.android/org.sfmldev.android.SFMLLoader}: java.lang.ClassNotFoundException: Didn't find class "org.sfmldev.android.SFMLLoader" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

I'm already tried to make relative path, disable instance run, clean project, restart android studio, restart OS, delete .idea and .gradle


Solution

  • Just forgot to remove android:hasCode="false" from AndroidManifest.xml