gpt4 book ai didi

java - Android Activity 类不存在

转载 作者:行者123 更新时间:2023-11-29 04:59:41 25 4
gpt4 key购买 nike

我在使用 Android Studio 时遇到错误,这让我非常生气。我有一个带有显示标记的 Google map 的应用程序。一切正常,但后来我添加了一个自定义标记 View ,以便以更好的方式显示信息,当我在我的设备上重新安装该应用程序时,它开始给我这个错误:

开始:Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.rioma.mapaclientescercanos/.ActivityMaps } 错误类型 3 错误: Activity 类 {com .rioma.mapaclientescercanos/com.rioma.mapaclientescercanos.ActivityMaps} 不存在。

问题是应用程序安装正确,但似乎找不到运行它的主要 Activity 。我还有另一个应用程序,我试图通过 Intent 从中启动这个应用程序并且之前一直在工作,但现在不是了。我已经检查了与包名称、应用程序 ID 有关的所有内容,尝试重命名包,将项目复制到另一个新项目,但它根本不起作用。我第一次安装应用程序时它启动正确,但第二次安装时出现错误。即使第一次尝试从其他应用程序启动它也无法正常工作。删除自定义标记 View 没有帮助。我已经尝试过这里发布的一些解决方案,比如 this one , 和 this other ,但没有工作。还尝试更改 compileSdk、targetSdk 和 buildTools 版本,但没有结果。

发布我的 list 和 gradle.build:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.rioma.mapaclientescercanos.ActivityMaps"
android:label="asd" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>



</application>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:glEsVersion="0x00020000"
android:required="true"/>

Gradle.build:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId 'com.rioma.mapaclientescercanos'
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.google.maps:google-maps-services:0.1.7'
compile files('libs/jtds-1.2.8.jar')
}

希望你能帮助我,因为我工作需要这个。

编辑:

好的,我发现问题与这段代码有关:

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, ActivityMaps.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP );

我需要这个应用程序不出现在应用程序抽屉中,所以我添加了这段代码。当我在没有此代码的情况下重新安装时,它运行良好,但在我添加它的那一刻,错误就出现了。我将检查是否有另一种方法可以将应用程序图标隐藏在抽屉中。它可能与此特定代码有关,可能隐藏包名称或其他内容。

最佳答案

在您的 gradle 文件中,您必须保持相同的 SDK 级别、构建工具和支持/appcompat 库以避免出现奇怪的行为。当您使用构建工具 22 时,尝试将 compileSdkVersion 21 更改为 22 以及 support-v4。

注意Appcompat-v7 包含 support-v4,所以你不需要添加它。

关于java - Android Activity 类不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32500069/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com