这是我按下电话上的按钮后的logcat:
我已经在清单中插入了请求权限的命令,但可能需要更多的东西:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.never.mediaalarmplayer">
android:versionCode = "1"
android:versionName="1.0">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:fullBackupContent="@xml/backup_descriptor">
<activity android:name=".Alarm"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MediaPlayer"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:label="@string/app_name"
/>
<service android:name="com.never.mediaalarmplayer.MusicService" />
<receiver android:name=".AlarmReceiver"/>
</application>
</manifest>
Logcat 2.9:
09-02 06:34:47.269 666-677/system_process I/ActivityManager: START u0 {cmp=com.never.mediaalarmplayer/.MediaPlayer} from uid 10060 on display 0
09-02 06:34:47.269 666-723/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client; transfer 4, track 48000 Hz, output 44100 Hz
09-02 06:34:47.313 1148-1167/android.process.media E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=2012, uid=10060 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:605)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:480)
at android.content.ContentProvider$Transport.query(ContentProvider.java:211)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
at android.os.Binder.execTransact(Binder.java:507)
09-02 06:34:47.313 2012-2012/com.never.mediaalarmplayer D/AndroidRuntime: Shutting down VM
09-02 06:34:47.318 2012-2012/com.never.mediaalarmplayer E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.never.mediaalarmplayer, PID: 2012
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.never.mediaalarmplayer/com.never.mediaalarmplayer.MediaPlayer}: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=2012, uid=10060 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=2012, uid=10060 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1599)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:491)
at android.content.ContentResolver.query(ContentResolver.java:434)
at com.never.mediaalarmplayer.MediaPlayer.getSongList(MediaPlayer.java:138)
at com.never.mediaalarmplayer.MediaPlayer.onCreate(MediaPlayer.java:41)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
READ_EXTERNAL_STORAGE是自Android6.0以来的运行时权限。在清单中添加权限请求是不够的。应用程序应该在运行时请求权限。如果你不想那么做,换到22或更少。
崩溃的原因存在于GenyMotion的实现中。IMHO(我猜),GenyMotion2.8中的MediaProvider不能访问外部存储,但2.9可以。
在logcat我看到了这个- 需要关于发生了什么以及如何解决的建议。我使用的是android studio北极狐2020.3.1补丁3。
09-08 07:58:32.915 137 26-13726/com.ruthadeaton.bld3.calculator e/androidruntime:致命异常:main process:com.ruthadeaton.bld3.calculator.calculator,PID:13726 java.lang.numberformatexception:empty string ats
问题内容: 我一直试图在Eclipse中制作我的第一个android应用程序(一个简单的温度转换器),但是当我单击手机上的按钮时,该应用程序崩溃了。这是完整的Java代码 单击按钮时的LogCat 最后是按钮的xml 我不确定如何解决此问题,因此希望有人可以提供帮助。谢谢。 问题答案: 首先初始化您的按钮,然后将onclicklistener设置为它们 同样设置另一个按钮
我多次尝试让developers.android(https://developer.android.com/training/basics/firstapp/index.html)上的MyFirstApp教程中的应用程序发挥作用。我正在Nexus4设备上测试我的代码,该设备装有Android 4.4.2 AndroidManifest.xml: MainActivity.java Display
E/AndroidRuntime:致命异常:主进程:com。维内特。计算器,PID:29435 java。lang.NullPointerException:尝试调用虚拟方法的布尔java。朗,布尔<代码>在此输入代码booleanValue()”在com的空对象引用上。维内特。计算器主要活动16美元。android上的onClick(MainActivity.java:177)。看法看法andr
该应用程序在API26模拟器中运行良好,没有任何意外行为,但在API23中崩溃。当应用程序启动时。我对android相当陌生,所以不太确定要做什么改变来适应API23。 这是我的年级