我正在编写一个新的应用程序,我尝试使用不同的版本。当我在Nougat尝试时,我的应用程序无法打开。它只是说:
应用已停止。再次打开应用程序?
如果我再次按下打开,应用程序会一直停止。
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "2.0"
multiDexEnabled true
}
}
我尝试使用buildToolsVersion“25.0.1”和nope。有什么帮助吗?
当我尝试在Nougat设备中打开它时,这是我的logcat跟踪
05-10 09:49:35.119 4709-4709/app E/app: /storage/emulated/0/app/Registros/grupo-registros.csv (No such file or directory)
java.io.FileNotFoundException: /storage/emulated/0/app/Registros/grupo(demo)-registros.csv (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:140)
at app.MainActivity.onCreate(MainActivity.java:175)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
05-10 09:49:35.148 4709-4709/app D/AndroidRuntime: Shutting down VM
05-10 09:49:35.148 4709-4709/app E/AndroidRuntime: FATAL EXCEPTION: main
Process: app, PID: 4709
java.lang.RuntimeException: Unable to start activity ComponentInfo{es/app.MainActivity}: java.util.EmptyStackException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.util.EmptyStackException
at app.MainActivity.copyFileOrDir(MainActivity.java:434)
at app.MainActivity.addSubjectDemo(MainActivity.java:341)
at app.MainActivity.onCreate(MainActivity.java:231)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
编辑:我的清单许可请求
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
答案 0 :(得分:1)
java.io.FileNotFoundException:/storage/emulated/0/app/Registros/grupo(demo)-registros.csv (No such file or directory)
这可能是因为在Nougat-Android 7.0中,对权限的更改可能会影响您的应用。它没有强制执行,但它会弹出您可能无法处理的异常。您应该阅读文档:
https://developer.android.com/about/versions/nougat/android-7.0-changes.html
并查看此答案