1

Okay, so I've tried to import my unity project as a single activity in Android Studio.
I've followed this tutorial but I kept getting an error at step 6:
"Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve project..."

So I turned to another tutorial on a different way to import the aar package to my main project file in android studio.

Now, using both of the tutorials together, I managed to put something together that will compile without an error.

This is my main activity, where I want to start the unity activity on a button click:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void startUnity(View view){
    Intent intent = new Intent(this.getApplicationContext(), UnityPlayerActivity.class);
    startActivity(intent);
}
}

The UnityPlayerActivity class is recognized by Android Studio, but when I run the app, I get this exception:
"Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.zackguetta.foodiedoodie/com.unity3d.player.UnityPlayerActivity}; have you declared this activity in your AndroidManifest.xml?"

How do I fix this? I thought the merge of the manifests would take care of this.

*note: I'm using Android Studio 3.0.1 if it means anything to you (maybe some compatibility issues arise)
*second note: Yes, I went through the other similar topics, none seemed to have the answer, so please don't mark as a duplicate right away.

1
  • Not a duplicate? Have you tried this?
    – Programmer
    Commented Jan 11, 2018 at 18:05

1 Answer 1

1

Add it to your AndroidManifest.xml. Write this line inside <application> tags:

<activity android:name=".unity3d.player.UnityPlayerActivity" />
1
  • I can't import it, Android Studio doesn't recognize it. it's an aar library that's imported as a module. Commented Jan 11, 2018 at 9:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.