为什么我无法为较低的Android版本构建应用?

时间:2016-05-29 12:29:29

标签: android sdk

我使用Android Studio,开始使用SDK版本23来编写和构建应用程序,一切运行正常。但该应用程序只适用于手机将Android 5.0及以上。 我想为Andriod 4.4制作一个新版本。所以我在Android Studio下载SDK 19,然后点击app - >打开模块设置 - >味道 - > miniSdkversion为19.可以编译,但在运行时不能正常工作并获得跟随错误。 然后我还将targetSDK Version设置为19.相同,得到以下错误:

29 20:17:44.698 3699-3699 / com.hanjing.flocking E / AndroidRuntime:致命异常:主要                                                                     java.lang.ExceptionInInitializerError                                                                         at java.lang.Class.newInstanceImpl(Native Method)                                                                         在java.lang.Class.newInstance(Class.java:1319)                                                                         在android.app.Instrumentation.newActivity(Instrumentation.java:1068)                                                                         在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)                                                                         在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)                                                                         在android.app.ActivityThread.access $ 700(ActivityThread.java:140)                                                                         在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1237)                                                                         在android.os.Handler.dispatchMessage(Handler.java:99)                                                                         在android.os.Looper.loop(Looper.java:137)                                                                         在android.app.ActivityThread.main(ActivityThread.java:4921)                                                                         at java.lang.reflect.Method.invokeNative(Native Method)                                                                         在java.lang.reflect.Method.invoke(Method.java:511)                                                                         在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1038)                                                                         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)                                                                         at dalvik.system.NativeStart.main(Native Method)                                                                      引起:java.lang.UnsatisfiedLinkError:无法加载库:reloc_library [1307]:1874无法找到' rand' ...

                                                                    at java.lang.Runtime.loadLibrary(Runtime.java:370)
                                                                    at java.lang.System.loadLibrary(System.java:535)
                                                                    at com.example.mac.flocking.MainActivity.<clinit>(MainActivity.java:37)
                                                                    at java.lang.Class.newInstanceImpl(Native Method) 
                                                                    at java.lang.Class.newInstance(Class.java:1319) 
                                                                    at android.app.Instrumentation.newActivity(Instrumentation.java:1068) 
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025) 
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 
                                                                    at android.app.ActivityThread.access$700(ActivityThread.java:140) 
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 
                                                                    at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                    at android.os.Looper.loop(Looper.java:137) 
                                                                    at android.app.ActivityThread.main(ActivityThread.java:4921) 
                                                                    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:1038) 
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 
                                                                    at dalvik.system.NativeStart.main(Native Method) 

如果我还将编译版本和buildtool版本设置为19,则编译时会显示错误。

所以我不知道该怎么做。我只是想制作一个可以在较低的Android手机上运行的新版本。

请帮忙!非常感谢你!

这是build.gradle: //顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项。

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

1 个答案:

答案 0 :(得分:0)

检查错误:

Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1307]: 1874 cannot locate 'rand'...

您是否使用了较低Android版本中没有的任何代码?