Reputation: 31
I'm getting an error with Android Studio that's getting me really mad. I have an application with a Google Map that displays markers. It all was working well, but then I added a Custom Marker View so that the info displays in a better way, it started to give me this error when I reinstalled the app on my device:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.rioma.mapaclientescercanos/.ActivityMaps } Error type 3 Error: Activity class {com.rioma.mapaclientescercanos/com.rioma.mapaclientescercanos.ActivityMaps} does not exist.
The thing is that the app is installed correctly, but it seems it does not find the main activity to run it. I also have another app from which I'm trying to launch this one via Intent and was working before, but now it isn't. I have checked everything that has to do with packages names, application id, tried renaming the package, copying the project to another new one, but it just won't work at all. The first time I install the app it launches correctly, but the second time I do it the error comes up. Even trying to launch it from the other app the first time it won't work. Removing the Custom Marker View doesn't help. I have tried some solutions posted here, like this one, and this other, but none work. Also tried changing compileSdk, targetSdk and buildTools version without result.
Posting my manifest and 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')
}
Hope you can help me, as I need this for work.
EDIT:
Okey, I have found that the problem has something to do with this code:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, ActivityMaps.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP );
I need this application not to appear in the Application Drawer, so i added this code. When I reinstall without this code, it works well, but in the moment I add it the error comes out. I'll be checking if there's another method of hiding the app icon in the drawer. It might has something to do with this specific code, could hide package name or something.
Upvotes: 2
Views: 2374
Reputation: 31
Finally I got a way to hide the app icon without it throwing any error. In my manifest I just simply removed the category line of my main activity:
<category android:name="android.intent.category.LAUNCHER" />
Like this:
<activity
android:name=".ActivityMaps"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
This way, I can launch this app via intent from another one, adding these lines of code:
ComponentName lComponentName= new ComponentName("com.rioma.mapaclientescercanos", "com.rioma.mapaclientescercanos.ActivityMaps");
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.setComponent(lComponentName);
launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Works perfectly like this. Thanks anyway for the replies.
Upvotes: 1
Reputation: 6703
Into your gradle file, you have to keep the same SDK level, build tool and support/appcompat library to avoid strange behavior. As you are using the Build tool 22, try to change compileSdkVersion
21 to 22 and also the support-v4.
note Appcompat-v7 include support-v4, so you don't need to add it.
Upvotes: 2
Reputation: 5061
AndroidManifest.xml file change this line android:name="com.rioma.mapaclientescercanos.ActivityMaps"
to android:name=".ActivityMaps"
Upvotes: 0