How to get google ads sdk to work in Intellij? - android

Silly question (noob here) but the tag below in AndroidManifest.xml doesnt work in IntelliJ. The app compiles successfully but crashes on launch. This manifest file works fine in Eclipse. I added the googleadmob*.jar file in the sdk part of the project structure settings.
<activity
android:name="com.google.ads.AdActivity"
...
</activity>

The problem is that you've added the jar to the SDK. It must be configured as a module library instead, refer to the documentation. In this case it will be packaged with your application, while SDK is not packaged as it's already available on the device.
If the class is still shown in red in the editor, try File | Invalidate Caches.

Related

Could not identify launch activity: Default Activity not found after upgrading to Android Studio 4.0

I've been having this problem since upgrading to Android Studio 4.0 on macOS. When I try to start my app from Android Studio, I get the following error:
Could not identify launch activity: Default Activity not found
Error while Launching activity
What's a bit unique about my project is that the default activity is defined in the manifest of another library used by my project, not the project itself. This was all working fine before the upgrade, but now it isn't for me. When I open the project containing the dependency, it builds and runs fine. I've already tried the following steps:
clean the project, rebuild
invalidate caches and restart
reinstall Android Studio
delete all generated files and folders (build, gradle, .idea, etc)
You can solve the problem as follows:
Click your Module Selection window,then click Edit Configurations…
Then set Launch Options to Nothing; that's okay:
To dovetail off of Mike N.'s comment, it looks like it is an issue to be resolved in the next point release: https://issuetracker.google.com/issues/158019870
For the details of the quick fix, for me I looked at the Merged Manifest tab, which is at the bottom-left of the AndroidManifest.xml pane. This shows all of the library manifests combined with your activity's.
The dialog said an error occurred where browser:1.0.0 manifest had a minSdk of 15 whereas all the rest of my minSdk are 14. I clicked on:
use a compatible library with a minSdk of at most 14, or increase this
project's minSdk version to at least 15.
Which brought up my minSdk to 15, and the error with the launcher went away, it will now insta-launch on my device. So I would sit tight for AS 4.0.1 but in the meantime, check the Merged Manifest.
For me this was happening in a project in which the main activity was declared in the manifest of an imported module (e.g. not in "app" module).
The solution for me was to add again the activity declaration in the manifest file of my top project:
<activity android:name="com.cristian_slav.elements.MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
On my side it was a issue with the manifest. You can detect this type of issue by watching the merged manifest tab. For more details you can watch the link shared by Mike N. in the first comment.
The problem will arise in new projects when one forgets to tick the default activity checkbox during adding anyone of the first or subsequent new activity.
This can be rectified at later stage by going to Run> Edit Configurations > Launch : in which change to specified activity and select the activity you choose to keep as the first page on launch of app.
Try these steps:
Close Android Studio
Go to
C:\Users\my_user_name.AndroidStudio4.0\system\caches
Delete "caches" folder
Relaunch Android Studio
set Launch Options to (Nothing)

How to repair gradle sync and project build in android studio?

I'm new to android studio. I recently made a new project with default MainActivity, then deleted the activity and made a new Activity that i set as default in AndroidManifest.xml by adding
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Since I did that, my whole android studio broke down. I couldn't run any app I previously made or any project I created since then. After hitting run/Shift+F5 it just says
Error running 'app': Default Activity not found
It does this on any project I open/newly create. I am not able to launch with default or any activity, it just says that it isn't declared in manifest file. If it is a newly generated project, it usually won't even launch. I have to sync it with gradle files. After that I am able to sometimes run it, but after every android studio restart it breaks again. Some of my bigger projects were able to start after around 4-5 clean projects and gradle syncs, but broke down again after android studio restart. I have reinstalled android studio and build tools multiple times and I am all out of ideas. Every build or gradle sync is successful without errors, it just can't find the activity to run.
If none of these other troubleshooting options work, such as Invalidate Cache/Restart and Syncing Gradle, it may be the project setup itself.
Most Android Studio projects need at least one module. A module is a way to divvy up the source code based on different devices being targeted (e.g., you may need one for Android TV, one version of your app for Android Wearables, etc.). You can find more info here on that: https://developer.android.com/studio/projects/add-app-module
So make sure you have a module (typically named app or if it's the only one, lower-case version of your app's name maybe). It should have the source code, assets & res folders (drawables and launcher icons and such), the AndroidManifest.xml, and its own build.gradle file separate from the main project's. It doesn't have to have much in there other than where to look for library repositories.
Just ran into this issue when migrating an old project to Android Studio 4.0, this seemed to do the trick.
EDIT: Still working on it, looks like it will run the first time and then it recognizes "No Default Activity" and stops me from running/installing.
EDIT: Figured it out. It is a new issue with AS 4.0 where the merged manifests had a library (from androidx compatability library) that targeted minSdk=15 instead of 14 like I previously had. It appears when I click on that error in the Merged Manifest tab when I have AndroidManifest.xml open (bottom-left of the pane) I am able to run as normal again. See here: https://issuetracker.google.com/issues/158019870

INSTALL_FAILED_MISSING_SHARED_LIBRARY?

Basically I am developing an android app. Icreated a new library project and generated the aar file. Next in my main project I imported the aar file, added dependecy in my main project app module. Everything is fine till this point.
I wanted to use an activity instance of the aar library into my main project. So I added
<uses-library android:name="com.mylibray.project" android:required="true" />
in the main android manifest.
While installing it in android device/emulator getting INSTALL_FAILED_MISSING_SHARED_LIBRARY error. How to solve this?
I have solved this problem by using Google APIS/Intel Atom x86 as CPU in the emulator, without Google APIS I always get that error you said. ;)

Uploaded Android APK marked as Android Auto when not set in manifest

I've looked through my whole project directory, and for the life of me, I cannot find where it would think it is an Android Auto. Going through this page:
https://developer.android.com/training/auto/start/index.html#auto-metadata
Nowhere in my Android manifest, do I set an automotive.
Could a library add to the manifest to make it an Automotive app?
Are there other things in the manifest I can check?
Please cross check in your res/xml file and see if you have any media or notification
under - uses element.
You can also check in your manifest file if you have added Car GMS package in the meta-data element.
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="#xml/your_auto_xml_file"
/>
If the library you are importing in happens to be from the merchant who builds up the customized DHU, then these lib can infuse those properties in your project. One easy way would be to remove the library and see if it resolves the issue.

Can I remove com.google.android.gms.version from AndroidManifest when I use gradle?

I wonder if I can remove this line safely:
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
from my AndroidManifest.xml when I use gradle to build my APK.
According to the website https://developers.google.com/android/guides/setup only when I choose "ECLIPSE WITH ADT" I have to add this line. For "ANDROID STUDIO" usage this is not mentioned.
But in my case I use Eclipse (with ADT) as IDE but I build with gradle. (Actually it is a libGDX project). So I added the play-services by using gradle:
compile "com.google.android.gms:play-services:8.1.0"
So I run the app on a test device and I tested to login with play-services and it worked fine without having the line above in my AndroidManifest.xml
But, maybe the login just does not need the "com.google.android.gms.version" value and another part of the play services lib needs it? But I cannot test all the possible ways to use the lib.
Does anybody know for sure?
Or for those of you who use Android Studio + play services: Does your AndroidManifest.xml have the line above?
Yes, as of Google Play services 7.0 (improved in 7.5 to remove the restriction on applying to the full play-services dependency), the <meta-data> tag is automatically added to your Manifest file by Gradle via Manifest merging.

Categories

Resources