Default Activity not found when using second activity in AndroidManifest

Lex9Lex9 USMember ✭✭

Hello
I have created a game using MonoGame framework, which under the hood is using Xamarin.Android
Now I want to profile it using this article: /en-us/xamarin/android/deploy-test/profiling (Sorry, it doesn't allow me to post a link)
On the step 10 it shows me this in Android Studio.
After some investigation, I have found that this happens, if you alter AndroidManifest.xml to add the external activity, like for advertisement:
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
If I remove it/comment out, I can successfully profile the application. Can someone, please, help me with this one? It is quite frustrating, to do this on every build/debug

Best Answer

  • Lex9Lex9 US ✭✭
    Accepted Answer

    I didn't found Manifest.xaml, I have only AndroidManifest.xml. So I have checked with rebuilding everything from the scratch with empty project in Xamarin. With the
    <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    So I cleaned everything in manifest and put these lines above the tag. That fixed the issue. Thanks for the help

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    I've tested the steps about Profiling Android apps and it works fine with the XamagonXuzzle sample.
    Check the followint points:

    • The version of Android Studio should be 3.0 and later.
    • Disable Use Shared Runtime in project build options.
    • Build the app for Debug, check step 2 and 3.

  • Lex9Lex9 USMember ✭✭

    @Jarvan said:
    I've tested the steps about Profiling Android apps and it works fine with the XamagonXuzzle sample.
    Check the followint points:

    • The version of Android Studio should be 3.0 and later.
    • Disable Use Shared Runtime in project build options.
    • Build the app for Debug, check step 2 and 3.

    Correct. That all works, because AndroidManifest.xml has <application> tag, which is empty. Try to add some activities to that manifest manually, by altering the <application> tag contents. Usually this is done by annotation [activity] on the class name, but if you try to add the Google Admob library from Nuget(Xamarin.GooglePlayServices.Ads.Lite) to the project (add the <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> to AndroidManifest.xml) you will see, that after this step Android Studio will complain, that it cannot find the default activity.
    As far, as I understand, this happens, because the manifet, which is generated based on the [activity] annotations, messes up with the manually added activities. So my question is - how to deal with those activities?

  • JarvanJarvan Member, Xamarin Team Xamurai

    Have you tried to use Xamarin Profiler to Profiling Android Apps? Will the same error occur?
    https://docs.microsoft.com/en-us/xamarin/tools/profiler/?tabs=windows

  • Lex9Lex9 USMember ✭✭
    > @Jarvan said:
    > Have you tried to use Xamarin Profiler to Profiling Android Apps? Will the same error occur?


    No, I haven't. I'm a student right now, so it's perfectly fine for me to use community version of Visual Studio. Moreover, I haven't enough space on my HDD to store more packages from Enterprise version.
    So, basically, it is impossible to do such thing from Android Studio profiler?
  • JarvanJarvan Member, Xamarin Team Xamurai
    edited November 25

    I tested profiling Android apps on Android Studio with adding com.google.android.gms.ads.AdActivity code. No error occured. Have you added the <meta-data> code in Manifest.xaml? You should ensure the sampl work well on VS.

  • Lex9Lex9 USMember ✭✭
    Accepted Answer

    I didn't found Manifest.xaml, I have only AndroidManifest.xml. So I have checked with rebuilding everything from the scratch with empty project in Xamarin. With the
    <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    So I cleaned everything in manifest and put these lines above the tag. That fixed the issue. Thanks for the help

  • JarvanJarvan Member, Xamarin Team Xamurai

    Congrats! Please mark your solution as the answer. It'll help others who face the similar problem.

Sign In or Register to comment.