Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

AndroidManifest problem with Unity 5

Discussion in 'Android' started by Mark-Tang, Mar 7, 2015.

  1. Mark-Tang

    Mark-Tang

    Joined:
    Aug 5, 2014
    Posts:
    4
    Before upgrading to Unity 5 everything was almost fine.

    However when we upgraded to Unity 5 and build the Android version , Unity failed to detect touches. We finally found that it is because of the AndroidManifest. There is a conflict between Google IAB plugin and the Unity Android activities. Here is the AndroidManifest :

    Code (CSharp):
    1. <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    2.      
    3.         <activity android:label="@string/app_name"
    4.             android:name="com.iab.overrideActivity"
    5.             android:screenOrientation="landscape"
    6.         android:configChanges="locale|mcc|mnc|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
    7.  
    8.             <meta-data android:name="android.app.lib_name" android:value="unity" />
    9.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    10.          
    11.             <intent-filter>
    12.                 <action android:name="android.intent.action.MAIN" />
    13.                 <category android:name="android.intent.category.LAUNCHER" />
    14.             </intent-filter>
    15.          
    16.          
    17.         </activity>
    18.  
    19.         <activity android:name="com.unity3d.player.UnityPlayerActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    20.      
    21.      
    22.      
    23.         </activity>
    24.         <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    25.  
    26.         </activity>
    27.  
    28.         <!-- AdMob Plugin -->
    29.         <activity android:name="com.google.ads.AdActivity"
    30.                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    31.                   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    32. </application>
    We have read the Plugins For Android Manual :
    http://docs.unity3d.com/Manual/PluginsForAndroid.html

    Here is the extending UnityPlayerActivity Java Code :
    Code (CSharp):
    1. public class overrideActivity extends UnityPlayerActivity {
    2.     public interface cbEvent{
    3.         public boolean cbEvent(int requestCode, int resultCode, Intent data);
    4.     }
    5.     protected cbEvent ie;
    6.     static protected overrideActivity inst;
    7.     protected void onCreate(Bundle savedInstanceState) {
    8.         super.onCreate(savedInstanceState);
    9.         inst =this;
    10.        
    11.         // print debug message to logcat
    12.         Log.d("overrideActivity", "onCreate called!");
    13.     }
    14.     @Override
    15.     public void onDestroy(){
    16.         super.onDestroy();
    17.         inst =null;
    18.         Log.d("overrideActivity", "onDestroy called!");
    19.     }
    20.     @Override
    21.     public void onActivityResult(int requestCode, int resultCode, Intent data){
    22.         Log.d("overrideActivity", "onActivityResult called!");
    23.        
    24.         boolean ret =false;
    25.         if (ie !=null){
    26.             try{
    27.                 ret =ie.cbEvent(requestCode, resultCode, data);
    28.             }
    29.             catch(Exception e){
    30.                 ret =false;
    31.             }
    32.         }
    33.         if (ret ==false){
    34.             super.onActivityResult(requestCode, resultCode, data);
    35.         }
    36.     }
    37.    
    38.     static public void registerOnActivityResultCBFunc(final cbEvent pcbfunc){
    39.         if (inst !=null)
    40.             inst.ie =pcbfunc;
    41.     }
    42. }
    Anything wrong or needed to change?

    P.S. Same thing happened in here :
    http://answers.unity3d.com/question...-works-on-android-in-unity-5.html?sort=oldest
     
    Last edited: Mar 7, 2015
  2. Riwels

    Riwels

    Joined:
    Aug 23, 2014
    Posts:
    2
    I'm stuck with this too. Did you find a workaround or something?
     
  3. Riwels

    Riwels

    Joined:
    Aug 23, 2014
    Posts:
    2
    Try this:
    Code (CSharp):
    1.  
    2.   <application
    3.   android:debuggable="false"
    4.   android:icon="@drawable/app_icon"
    5.   android:label="@string/app_name" >
    6.        <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="fullSensor" android:name="com.unity3d.player.UnityPlayerNativeActivity">
    7.        <intent-filter>
    8.          <action android:name="android.intent.action.MAIN" />
    9.          <category android:name="android.intent.category.LAUNCHER" />
    10.        </intent-filter>
    11.        <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    12.      </activity>
    13. <!-- AdMob Plugin -->
    14.         <activity android:name="com.google.ads.AdActivity"
    15.                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    16.                   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    17.   </application>
    18.  
    It's working to me, with Amazon Ads. Hope it helps you.