Search code examples
androidandroid-studioandroid-gradle-pluginruntime-errorwikitude

Error inflating class com.wikitude.architect.ArchitectView


I am using Android studio with Epson Wikitude's SDK. When I run the application it crashes and I am getting an inflate class error. I have looked at several other questions, but none of the was quite the same or worked for my problem.

/com.example.username.myapplication E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering /
    com.example.username.myapplication E / AndroidRuntime: FATAL EXCEPTION: main
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1091]: Library '/data/data/com.example.pmbi002.myapplication/libarchitect.so'
not found
at java.lang.Runtime.load(Runtime.java: 340)
at java.lang.System.load(System.java: 524)
at com.wikitude.architect.ArchitectView.e(Unknown Source)
at com.wikitude.architect.ArchitectView.a(Unknown Source)
at com.wikitude.architect.ArchitectView. < init > (Unknown Source)
at com.wikitude.architect.ArchitectView. < init > (Unknown Source)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java: 417) 
at android.view.LayoutInflater.createView(LayoutInflater.java: 586) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java: 680) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java: 739) 
at android.view.LayoutInflater.inflate(LayoutInflater.java: 489) 
at android.view.LayoutInflater.inflate(LayoutInflater.java: 396) 
at android.view.LayoutInflater.inflate(LayoutInflater.java: 352) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java: 280) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java: 140) 
at com.example.pmbi002.myapplication.MainActivity.onCreate(MainActivity.java: 30) 
at android.app.Activity.performCreate(Activity.java: 4465) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1049) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 1920) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 1981) 
at android.app.ActivityThread.access$600(ActivityThread.java: 123) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java: 1147) 
at android.os.Handler.dispatchMessage(Handler.java: 99) 
at android.os.Looper.loop(Looper.java: 137) 
at android.app.ActivityThread.main(ActivityThread.java: 4424) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java: 511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 784) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 551) 
at dalvik.system.NativeStart.main(Native Method) 

Build.gradle file:

   apply plugin: 'com.android.application'

   android {
       compileSdkVersion 15
       buildToolsVersion '22.0.0'
       defaultConfig {
           applicationId "com.example.myusername.myapplication"
           minSdkVersion 11
           targetSdkVersion 15
           versionCode 1
           versionName "1.0"
       }
       buildTypes {
           release {
               minifyEnabled false
               proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
           }
       }
       productFlavors {}
   }

   dependencies {
       compile fileTree(include: ['*.jar'], dir: 'libs')
       testCompile 'junit:junit:4.12'
       compile 'com.android.support:appcompat-v4:22.0.0'
       compile 'com.android.support:design:22.0.0'
   }

Solution

  • Android studio expects the native libraries to be at the lib folder inside the jar while they are in the libs folder so android studio can't find them.

    What you can do to fix this is:

    • make a copy of the jar
    • unzip it extract the libs folder
    • rename libs to lib and zip the lib folder
    • rename the new .zip to .jar

    and import it in your gradle file:

    dependencies{
        compile fileTree(dir: 'libs', include: '*.jar’)
    }
    

    This fixed it for me. It was also described in the wikitude forum: http://www.wikitude.com/developer/developer-forum/-/message_boards/message/858620#_19_message_858823

    Edit: You can also try to

    • set classpath ‘com.android.tools.build:gradle:1.5.0’ to ‘com.android.tools.build:gradle:1.3.0’ in build.gradle from your project
    • make sure the compileSdkVersion, targetSdkVersion and com.android.support-v4 are 22 or lower

    This should not be a problem because the Epson Moverio BT-200 runs on Android 15

    Edit: This gradle setup solved the problem for me: /app/build.gradle:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
    
        defaultConfig {
            applicationId "com.wikitude.sdksamples"
            minSdkVersion 9
            targetSdkVersion 22
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile 'com.android.support:support-v4:21.0.3'
        compile fileTree(dir: 'libs', include: '*.jar')
    }
    

    project build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.0'
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    

    As i mentioned in the comments, there is an Wikitude Epson SDK update coming soon which should get rid of the complications with android studio.