How to call activity from a library module in android studio - java

I am trying to call an activity from a library module in my application. I keep getting the error
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.nextgis.mobile/com.nextgis.mobile.activity.MainActivity}; have you declared this activity in your AndroidManifest.xml?
I am calling the activity as
Intent intentGIS = new Intent(android.content.Intent.ACTION_VIEW);
intentGIS.setComponent(new ComponentName("com.nextgis.mobile",
"com.nextgis.mobile.activity.MainActivity"));
startActivity(intentGIS);
App manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.disarm.sanna.pdm">
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission-sdk-23 android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.READ_SYNC_STATS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<!--
<uses-permission android:name="android.permission.CAMERA"/>
-->
<uses-feature
android:name="android.hardware.location"
android:required="true"
/>
<uses-feature
android:name="android.hardware.telephony"
android:required="false"
/>
<uses-feature
android:name="android.hardware.wifi"
android:required="false"
/>
<!--
<uses-feature
android:name="android.hardware.camera"
android:required="false"
/>
<uses-feature
android:name="android.hardware.compass"
android:required="false"
/>
-->
<supports-screens
android:largeScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:normalScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
/>
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:node="replace">
<activity
android:name=".SplashActivity"
android:windowSoftInputMode="stateHidden|adjustUnspecified"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.disarm.sanna.pdm.ShareActivity"
android:label="#string/app_name">
</activity>
<activity android:name=".SelectCategoryActivity"
android:label="#string/app_name">
</activity>
<activity android:name=".SocialShareActivity"
android:label="#string/app_name">
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".ActivityList"
android:windowSoftInputMode="stateHidden|adjustPan"
android:theme="#style/Theme.AppCompat.DayNight.NoActionBar">
</activity>
<activity
android:name=".Capture.Photo"
android:theme="#style/AppCompatAlertDialogStyle"
>
</activity>
<activity
android:name=".Capture.Video"
android:theme="#style/AppCompatAlertDialogStyle"
>
</activity>
<activity
android:label="Record Audio"
android:name=".Capture.AudioCapture"
android:theme="#style/Theme.AppCompat.Light.Dialog"
>
</activity>
<activity
android:label="#string/allow_setting"
android:name=".WriteSettingActivity"
android:theme="#style/AppTheme"
>
</activity>
<service
android:name=".Service.SyncService"
android:enabled="true"
android:exported="true" />
<service android:name=".DisarmConnect.MyService" />
</application>
</manifest>
Library manifest :
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Project: NextGIS Mobile
~ Purpose: Mobile GIS for Android.
~ Author: Dmitry Baryshnikov (aka Bishop), bishop.dev#gmail.com
~ Author: NikitaFeodonit, nfeodonit#yandex.com
~ Author: Stanislav Petriakov, becomeglory#gmail.com
~ ******************************************************************************
~ Copyright (c) 2012-2016 NextGIS, info#nextgis.com
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nextgis.mobile"
>
<application
android:allowBackup="true"
android:label="#string/app_name"
>
<activity
android:name=".activity.MainActivity"
android:label="#string/app_name"
>
</activity>
<activity
android:name=".activity.SettingsActivity"
android:label="#string/action_settings"
/>
<activity
android:name=".activity.NGWSettingsActivityProxy"
android:label="#string/ngw_settings"
/>
<activity
android:name=".activity.AboutActivity"
android:label="#string/action_help"
/>
<activity
android:name=".activity.CreateVectorLayerActivity"
android:label="#string/create_layer"
android:screenOrientation="portrait"
/>
<service
android:name="com.nextgis.mobile.datasource.SyncService"
>
<intent-filter>
<action
android:name="android.content.SyncAdapter"
/>
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="#xml/syncadapter"
/>
</service>
<provider
android:name="com.nextgis.maplib.datasource.LayerContentProvider"
android:authorities="com.nextgis.mobile.provider"
android:exported="false"
android:syncable="true"
/>
</application>
</manifest>
I have added compile project(':gisapp') in the gradle file for the module app. I know gradle does manifest merging automatically but I could be wrong.
What am I doing wrong here ?
Note : This is the project which I am using as library.

Related

Java class requires permission but its already stated in android manifest

I'm making an application integrated to gcm and I'm keep getting error at this point.
String regid = gcm.register(Common.getSenderId());
Where the word "register" is covered with horizontal line in middle requesting permission com.google.android.c2dm.permission.RECEIVE
I have that permission on my android manifest file but still it keep showing horizontal line and requires permission.
I'm following this tutorial : http://www.appsrox.com/android/instachat/
This is my manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.heylo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<permission
android:name="com.example.heylo.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.heylo.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<application
android:name="com.example.heylo.Common"
android:allowBackup="true"
android:icon="#drawable/ic_splash"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
<activity android:name=".SplashScreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.example.gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.heylo" />
</intent-filter>
</receiver>
<provider
android:name="com.example.heylo.DataProvider"
android:authorities="com.example.heylo.provider"
android:exported="false" >
</provider>
<activity
android:name=".Message_List"
android:label="#string/title_activity_message__list" >
</activity>
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings" >
</activity>
</application>
</manifest>

Eclipse NoClassDefFoundError

I'm developing an application using Google Maps. It references the Google Map Util library project, which references google play services library and appcompat-v7. Here is my workspace:
https://www.dropbox.com/s/cwy2o9di7bk74li/Zrzut%20ekranu%202014-12-14%2016.21.07.png?dl=0
And yet, if I try to compile and run the application, it instantly crashes, with the following trace:
12-14 16:14:24.063: E/AndroidRuntime(7592): FATAL EXCEPTION: main
12-14 16:14:24.063: E/AndroidRuntime(7592): java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.LatLng
12-14 16:14:24.063: E/AndroidRuntime(7592): at michal.myapp.activities.StartupScreenActivity.onCreate(StartupScreenActivity.java:36)
So apparently the compiler has trouble finding google play services jars. Any ideas?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="michal.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<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="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCELEROMETER"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="michal.myapp.activities.MapActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="michal.myapp.activities.StartupScreenActivity"
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="michal.myapp.activities.CameraActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<!-- configure this activity to use landscape orientation -->
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/api_key"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Plus, checked the class folders, and they do exist at the locations pointed in the Manifest.
Okay, I added back Android Private Libraries to the build path (removed them because I had JAR mismatches because of it), but now it seems to work. I'll mark the answer as correct.
You must follow the oficial steps by Google to nice configuration of library : https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api

Error on google maps

I have this error: Google Maps Android APIļ¹• Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors)
I must say that I have requested API key with the debug keystore and I do have the needed permissions. Here is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tripin.corinaracasan.tripin"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="com.example.googlemaps.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="com.tripin.corinaracasan.tripin.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
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:label="#string/app_name" android:name=".MarkItemClass"/>
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="................................." />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>

AndroidRunTime NoClassDefFoundError

I am busy with an Android project with the android-support-v7-appcompat library for ActionBar, I have followed the description on Android Developer
but I have got every time NoClassDefFoundError: eu.definecontent.fazilet.HomeFragment.
I can not find where is wrong in the code or configuration, maybe you can find it, I would be glad if you could help me:
MainActivity:
public class MainActivity extends ActionBarActivity {
...
Fragment fragment = new HomeFragment();
...
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.definecontent.fazilet"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" >
</uses-permission>
<application
android:name=".FaziletApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat" >
<activity
android:name="eu.definecontent.fazilet.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".service.FillDailyTimetableService" />
<activity
android:name=".helper.DownloadManager"
android:theme="#android:style/Theme.Dialog" />
<activity android:name=".CitySettingActivity" />
<activity android:name=".LocationSettingActivity" />
</application>
and configuration are:
Thanks to G V have Finally fixed that!
just added a try catch statement to initialize a static class and everythings works now!
for more info plz see this article:
javareferencegv.blogspot.com

Android. No Launcher activity found?

When I'm trying running my app:
No Launcher activity found!
The launch will only sync the application package on the device!
I've readed all questions about similar problems, I changed my manifest.xml but every time I get same error. I stucked for an hour trying to solve this and nothing works.
Here's my manifest fragment:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mosbin"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_OWN_KEY" />
/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mosbin.MainActivity"
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="com.example.mosbin.Run"
android:label="#string/title_activity_run"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
<activity
android:name=".Stats"
android:label="#string/title_activity_stats"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
</application>
</uses-sdk>
What's wrong with this code?
Before it appears I just wanted to add new activity ...
< /uses-sdk > clear this tag at the end of your manifest and change this
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" > missing / here
to :
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
Also take these into your application tag :
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_OWN_KEY" />
https://developers.google.com/maps/documentation/android/start.
Check the link and the topic under Adding the API Key to your application
This is what you Manifest should look like:
Do note how the various tags have been opened and closed. And nested where required.
Also, read up on the Android Manifest Docs. That will ensure there is no confusion in the future. ;-)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mosbin"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" >
</uses-sdk>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_OWN_KEY" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mosbin.MainActivity"
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="com.example.mosbin.Run"
android:label="#string/title_activity_run"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
<activity
android:name=".Stats"
android:label="#string/title_activity_stats"
android:parentActivityName="com.example.mosbin" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mosbin" />
</activity>
</application>
</manifest>

Categories