Android Studio在运行时无法找到类

时间:2017-07-18 16:20:48

标签: java android android-studio

我有一个奇怪的问题,我在我的项目中包含了一个类,所有内容都构建,但是当它运行时崩溃说它无法找到该类。

我正在使用SlidingUpPanelLayout

https://github.com/umano/AndroidSlidingUpPanel

这是崩溃:

            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
         at dalvik.system.NativeStart.main(Native Method) 
      Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sothree.slidinguppanel.SlidingUpPanelLayout" on path: DexPathList[[zip file "/data/app/com.example.ns.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ns.app-1, /vendor/lib, /system/lib]]
         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
         at android.view.LayoutInflater.createView(LayoutInflater.java:559)
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
         at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
         at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
         at com.example.ns.app.MainActivity.onCreate(MainActivity.java:92) 
         at android.app.Activity.performCreate(Activity.java:5133) 
         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2227) 

这是gradle:

  apply plugin: 'com.android.application'

  android {
  compileSdkVersion 24
  buildToolsVersion "23.0.3"
  dexOptions {
      javaMaxHeapSize "8g"
  }
  defaultConfig {
      applicationId "com.example.ns.app"
      minSdkVersion 16
      targetSdkVersion 24
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
  }
  buildTypes {
      release {
    minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  }

  packagingOptions {
      exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
      exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
  }
  configurations.all {
      resolutionStrategy.dependencySubstitution {
          substitute module('org.apache.commons:commons-io:1.3.2') with       module('commons-io:commons-io:1.3.2')
      }
      }
  }



  dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',       {
exclude group: 'com.android.support', module: 'support-annotations'
  })
  compile 'com.android.support:appcompat-v7:24.2.1'
  compile 'com.android.support:design:24.2.1'
  compile 'com.android.support:support-v4:24.2.1'
  testCompile 'junit:junit:4.12'
  compile 'com.github.amigold.fundapter:library:1.0'
  compile 'org.osmdroid:osmdroid-android:5.6.4'
  compile 'com.google.android.gms:play-services-location:9.6.1'
  compile 'com.sothree.slidinguppanel:library:3.3.1'
  compile 'org.apache.commons:commons-io:1.3.2'
  compile 'com.google.android.gms:play-services:11.0.2'
  }

1 个答案:

答案 0 :(得分:0)

defaultConfig {
        applicationId "com.ignite.a01hw909350.kolamdemo"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }
    }

abiFilters应用模块中添加build.gradle。同步并清理您的项目