【发布时间】:2018-05-22 00:34:13
【问题描述】:
我在我的真实设备小米米 4c 上开发,没问题。然后突然(我猜是系统更新后)我在尝试运行时遇到了这个错误:
Uploading file to: /data/local/tmp/be.sebsob.red
Installing be.sebsob.red
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/be.sebsob.red"
Aborted
Launching application: be.sebsob.red/be.sebsob.red.FullscreenActivity.
DEVICE SHELL COMMAND: am start -n "be.sebsob.red/be.sebsob.red.FullscreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=be.sebsob.red/.FullscreenActivity }
Error type 3
Error: Activity class {be.sebsob.red/be.sebsob.red.FullscreenActivity} does not exist.
(这是一个新的android studio默认全屏应用,没有任何改动)
我尝试过但没有解决问题:
- 清理/重建项目
- 重新导入项目
- 删除了构建目录
- 删除了~/.idea 和~/.gradle 目录
- 已删除 .iml 文件
- 将 Manifest.xml 中的活动命名从 .FullscreenActivity 更改为完整路径
- 重启我的手机/电脑/Android Studio
- 使用 Invalidate Caches / Restart...重新启动 Android Studio...
- 通过 adb kill-server 和 adb start-server 命令重新启动 adb
- 通过任务管理器杀死 abd 进程并重新启动
- 在我的手机上重新启用了开发者选项
- 撤销我手机上的 USB 调试授权
但是当我在我的其他设备(小米 Mi2S)上运行此应用程序时,它运行良好。
AND 当我在手机上手动复制 .apk(无法从 Android Studio 运行)时,它会安装并运行良好。 所以我想从Android Studio运行到我的手机时一定是一个特定的问题?可能是读/写访问权限错误吗? 有什么想法吗?
AndroidManifest.xml(默认,Android Studio 新建项目设置后未更改)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="be.sebsob.red">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle(模块:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "be.sebsob.red"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
}
谢谢
【问题讨论】:
-
你是不是通过adb把手机上的app删掉了,然后再安装一个新版本?
-
您的 adb 似乎存在错误。尝试分别通过 adb kill-server 和 adb start-server 命令重新启动它。而且莫里森的回答也必须奏效。
-
@MorrisonChang 我已经在没有 adb 的情况下删除了手机上的应用程序。但是我为测试所做的新的默认简单项目以前从未在我的手机上......
-
@UğurB 当我运行 adb kill-server 它说: * server not running * 当我然后运行 adb start-server 它说:* 守护程序没有运行。现在在端口 5037 上启动它 * * 守护进程已成功启动 * 但是当我运行该项目时,我仍然得到相同的初始错误
-
我尝试使用 abd adb shell am start -a android.intent.action.DELETE -d package:be.sebsob.red 删除应用程序,但后来在我的手机上我收到一条消息:“在已安装应用列表中找不到应用”
标签: android adb android-manifest