So I successfully compiled an android application that displays an ad:
![Android app with an ad][1]
Now, I want to use this in my android game. To do so, I take the following steps;
1. In eclipse, label my project as a library, which makes a jar
2. Replace `public class BannerSample extends Activity {` with `public class BannerSample extends UnityPlayerActivity {` (and add `import com.unity3d.player.UnityPlayerActivity;`)
3. Remove `setContentView(R.layout.activity_main);`
4. Now back in Unity, I put my newly created bannersample.jar in the Plugins/Android folder, along with the jars my app requires: android-support-v4.jar, classes.jar, google-play-services.jar
Finally, I need to create an Android Manifest in this folder to tell it to use my activity. As a starting point, I go to Temp/StagingArea in my game's directory, where I find the basic Manifest that it generates. Initially it looks like this:
Here is the manifest for my ad-display app:
However, no matter what I do, no combination of the two files work. And this is where I really need help. How do I merge these two files together? Adding the user permission is no problem, however I cannot get correct activity lines.
If I replace
> android:name="com.unity3d.player.UnityPlayerNativeActivity">
with
> android:name=".BannerSample">
Unity tells me this when I try to compile:
` Unable to find unity activity in manifest. You need to make sure orientation attribut is set to portrait manually.
UnityEditor.HostView:OnGUI()
In addition, as you can see in my app's manifest, I have the following two lines:
>
If I include the second line anywhere (meta-deta) then Unity fails to build my app everytime, giving me the following error:
> Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Users\Owner\Development\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\build-tools\android-4.4.2\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/Owner/Development/adt-bundle-windows-x86_64-20140321/adt-bundle-windows-x86_64-20140321/sdk/platforms/android-19\android.jar" -F bin/resources.ap_
With the exception of the above error, Unity will build the app but it will quit as soon as started. I have tried every combination of the two files in regards with the activities. I have even tried removing some of the jars. Please help, how do I successfully merge these two files? What activities do I include and exclude, and why?
[1]: /storage/temp/26194-workingad.png
↧