问题
Running aapt against my apk, I see that something is appending a hash in front of my activity name, where I'd normally expect to see my namespace. Here is the aapt output...
C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1>aapt dump badging c:\base.apk
package: name='fr.company.DematAEAT_Android' versionCode='1' versionName='1.0' platformBuildVersionName='4.0.4-1406430'
install-location:'auto'
sdkVersion:'11'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
application-label:'DematAEAT_Android'
application-icon-160:'res/drawable/icon.png'
application: label='DematAEAT_Android' icon='res/drawable/icon.png'
application-debuggable
launchable-activity: name='md5abda05033ab0415fc7a776c5d9734c74.MainActivity' label='DematAEAT_Android' icon='res/drawable/icon.png'
feature-group: label=''
uses-feature: name='android.hardware.touchscreen'
uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
main
other-activities
other-receivers
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--'
densities: '160'
native-code: 'arm64-v8a' 'armeabi' 'armeabi-v7a' 'x86' 'x86_64'
The problem is on the line that starts "launchable-activity". How can I create intents that point to my activity if it's buried in a namespace with a long, made-up and, I expect, frequently changing namespace?
回答1:
This was something added in a recent Xamarin.Android version, also announced in the changelog to prevent clashing names I guess.
You can circumvent this by either using the RegiterAttribute or by forcing a name in the ActivityAttribute:
[Register("myNamespace.ActivityName")]
[Activity()]
public class MyActivity : Activity {...}
or
[Activity(Name = "myNamespace.ActivityName")]
public class MyActivity : Activity {...}
来源:https://stackoverflow.com/questions/33897245/why-is-xamarin-appending-a-hash-as-a-namespace