Reputation: 317
Problem: I can only make “Android Library” Modules, makes an icon as a folder with what I take as books on the lower right hand side.. Unfortunately I can not make an “Android Library” run on an Device using Edit Run Configurations . . ..
Questions:
Can Android Studio have a module that can be made to run?
Can an “Android Library” be changed to module that can run?
Tried; Editing various files by hand using Android Studio: Module won't show up in "Edit Configuration" as a base. Then tracing the error messages Got one combination to run. BUT the project was unpredictable where changes in code where inconsistent.
Tried: Android Studio Main Menu - > File - > [Project Structure . . . AND New Module . . . ] all Wizards make an “Android Library”.
As An Aside:
Is their a Icon key for Android Studio that defines exactly what each folder is within 1: Project [pick whatever]. I found the IntelliJ icon key but is missing the Android Specific icons.
Thank you in advance, Mark_97.
DID: Change AndroidManifest.xml within the module
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=//. . .
<application
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
>
//. . .
</application>
</manifest>
ADD styles.xml to module File to AS:
enter code here<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
Change build.gradle
apply plugin: 'com.android.application'
android {
//. . .
defaultConfig {
applicationId “// same as module package name”
//. . .
}
buildTypes {
// . . .
}
}
dependencies {
// . . .
}
Add ic_launcher.png to all mipmap-.
Upvotes: 0
Views: 1584
Reputation: 80010
You can change a library to an application pretty simply. Go into the module's build.gradle file and change:
apply plugin: 'com.android.library'
to:
apply plugin: 'com.android.application'
You may also have to add an applicationId
under android.defaultConfig
.
Note that if you have other modules that depend on this library, those dependencies will break if you convert the library to an application: in Android Gradle, you're only allowed to depend on library modules, not application modules. If you need to both depend on it and also have it compile to an app, then you'll need to refactor that module into two parts; one that you can depend on, and the other that builds the app.
Upvotes: 5