Search Unity

Integrating Unity into Android App

Discussion in 'Android' started by eragon1452, Mar 28, 2018.

  1. eragon1452

    eragon1452

    Joined:
    Sep 11, 2017
    Posts:
    2
    Hello everyone,

    I've looked around a lot but I can't find an updated guide, that isn't more than a year old, on how to integrate a Unity project into an existing Android app and, for example, launch the Unity project at the press of a button within that app. If someone has knowledge on this topic or a link to an updated guide it would be much appreciated! :)
     
  2. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    There are some examples you can find on github, but there is no official guide, because it isn't officially supported. Basically you need to export your Unity project to Android Studio from Unity and add additional activities and dependencies that you use in your Android project. You have to decide if you want to build your project using Unity every time or just copy unity related files to an existing project.
     
  3. eragon1452

    eragon1452

    Joined:
    Sep 11, 2017
    Posts:
    2
    Thanks for the reply, it makes much more sense now why there aren't official guides. If possible, could you link me to those github projects that you were talking about? It would help a lot. Thanks :D
     
  4. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    I just googled "integrating unity with existing android app" and a bunch of things came up. There are some old articles, but I would look for newer ones, because a lot of changed after gradle was introduced.

    https://medium.com/@davidbeloosesky/embedded-unity-within-android-app-7061f4f473a
    https://github.com/TTimo/unity-android-example
     
  5. mikewarren

    mikewarren

    Joined:
    Apr 21, 2014
    Posts:
    109
    Good information here, thanks.

    I'm on a small team developing an AR app for ODG glasses. There's a 3D component to render objects in physical space and a 2D component with text and prompts to be rendered as an overlay. The 2D component would be much simpler to write as a standard Android/Java app (I've never written an Android App).

    Any suggestions for integrating the two applications? The 3D and 2D components are completely separate. Is it possible to create / run a Unity app with a regular app at the same time and use the same display space?
     
  6. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
  7. Jshell

    Jshell

    Joined:
    Dec 21, 2015
    Posts:
    2
    Hello! I've been working on this for a few weeks, right now I can help you launching a Unity scene from Android app
    Reply me or PM if you are still stuck on that :p
     
  8. mikewarren

    mikewarren

    Joined:
    Apr 21, 2014
    Posts:
    109
    Is it something you could post about here or maybe write a small article on Unity Connect? I'm not far enough along in my Android education to ask intelligent questions yet, but having something online could probably help out lots of people.
     
  9. yurykorzun

    yurykorzun

    Joined:
    Oct 29, 2015
    Posts:
    41
    I don't think I have time for that right now, but the idea is to export an android studio project Unity and explore it. It includes a UnityActivity, you can learn a lot by trying to understand what it does.
     
    sirvon likes this.
  10. Richardfalcos

    Richardfalcos

    Joined:
    Feb 5, 2014
    Posts:
    3
    [QUOTE = "eragon1452, post: 3442247, membro: 1511612"] Olá pessoal,

    Pesquisei bastante, mas não consigo encontrar um guia atualizado, com mais de um ano, sobre como criar um projeto do Unity em um aplicativo Android existente e, por exemplo, iniciar o projeto do Unity no pressionar um botão nesse aplicativo. Se alguém tiver conhecimento sobre este tópico ou um link para um guia atualizado, seria muito apreciado! :)[/ CITAR]
    Oi, há algum tempo atrás fizemos um título de apresentação para Dolly refrigerantes ou um aplicativo android que toda interação de realidade aumentada foi feita no UNITY. Não sei se esse aplicativo é aplicável a seu caso, mas em todo o caso está ai ... Na loja Play Store, baixe o APP estudos RFMK, este aplicativo ligue a câmera do seu smartphone, o deixe protegido para interação, faça um mapa brasil: https://www.shutterstock.com/pt/image-vector/flat-simple-brazil-map-vector-background-180560819 e você pode interagir usando um botão Android / Unity. se desejar ver mais exemplos: aponte o seu celular para o logotipo da animação:
    , outro exemplo: você pode usar uma nota de vinte reais no seu bolso / colocar o seu celular no lado de Deusa semémis, se não possuir uma nota real, veja esta: https://www.bcb.gov.br/novasnotas/ nota-20-reais.html . Seria isso que você precisa? Valeu...
     
  11. adrien_unity264

    adrien_unity264

    Joined:
    Jul 15, 2019
    Posts:
    4
    Hi all !

    I would like to make an android app from my unity project (in achieve a valid kiosk mode of my app).
    So I have exported my unity-kudan project, made an aar from it.
    And I make an android project that start my unity activity from my unity aar library.
    Everything is fine and the code compile without any problems, but the kudan detection doesn’t work at all.
    The camera doesn’t even start… but my unity sphere and cubes are correctly displayed.
    And my logcat says:

    Code (Boo):
    1. 2019-08-29 12:39:59.503 19591-19693/com.gogo.kiosk E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: eu.kudan.androidar.KudanAR
    2.     java.lang.ClassNotFoundException: eu.kudan.androidar.KudanAR
    3.         at java.lang.Class.classForName(Native Method)
    4.         at java.lang.Class.forName(Class.java:453)
    5.         at java.lang.Class.forName(Class.java:378)
    6.         at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    7.         at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    8.         at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source:114)
    9.         at android.os.Handler.dispatchMessage(Handler.java:101)
    10.         at android.os.Looper.loop(Looper.java:164)
    11.         at com.unity3d.player.UnityPlayer$c.run(Unknown Source:20)
    12.      Caused by: java.lang.ClassNotFoundException: Didn't find class "eu.kudan.androidar.KudanAR" on path: DexPathList[[zip file "/data/app/com.gogo.kiosk-30j2LcvVikeCmcYUA-2aJw==/base.apk"],nativeLibraryDirectories=[/data/app/com.gogo.kiosk-30j2LcvVikeCmcYUA-2aJw==/lib/arm, /data/app/com.gogo.kiosk-30j2LcvVikeCmcYUA-2aJw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
    13.    at dal
    14. 2019-08-29 12:39:59.513 19591-19693/com.gogo.kiosk E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.gogo.unity.MyPlugin

    Here’s my gradle file:

    Code (Boo):
    1. apply plugin: 'com.android.application'
    2.  
    3. android {
    4.     compileSdkVersion 29
    5.     buildToolsVersion "29.0.2"
    6.     defaultConfig {
    7.         applicationId "com.gogo.kiosk"
    8.         minSdkVersion 21
    9.         targetSdkVersion 29
    10.         versionCode 1
    11.         versionName "1.0"
    12.         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    13.  
    14.     }
    15.     buildTypes {
    16.         release {
    17.             minifyEnabled false
    18.             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    19.         }
    20.     }
    21.     compileOptions {
    22.         sourceCompatibility = 1.8
    23.         targetCompatibility = 1.8
    24.     }
    25. }
    26.  
    27. dependencies {
    28.     implementation project(":asepsie-release")
    29.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    30.     implementation 'androidx.appcompat:appcompat:1.0.2'
    31.     implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    32.     testImplementation 'junit:junit:4.12'
    33.     androidTestImplementation 'androidx.test:runner:1.2.0'
    34.     androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    35. }
    Any idea about this ?
    Thanks in advance !
     
  12. Am33n

    Am33n

    Joined:
    Apr 9, 2020
    Posts:
    3
    i like to learn from you
     
  13. pushpendra996

    pushpendra996

    Joined:
    Dec 8, 2018
    Posts:
    4