2

I need to setup a minimal Gradle & Android SDK project in order to test that a specific library can be used in this environment.

gradle init does not provide any options for Android.

How should I create a minimal compilable project for Android with gradle?

Answers here are outdated and were of no help for me.

andreoss
  • 1,570
  • 1
  • 10
  • 25

1 Answers1

2

You can try out this:

Use Gradle 6.1.1 and Android SDK 29.

settings.gradle

empty

build.gradle (example from the official docs):

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
    }
}
allprojects {
   repositories {
       google()
       jcenter()
   }
}
apply plugin: 'com.android.application'
android { compileSdkVersion 29 }
repositories { jcenter() }

src/main/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example">
</manifest>

Plenty of android boilerplates are also available on Github

Poliakoff
  • 1,592
  • 1
  • 21
  • 40
  • 1
    Is `allprojects` block really necessary? – andreoss Jul 08 '20 at 00:24
  • 1
    @andreoss not necessary, just for convenience on multi-module project. Otherwise, that block has to be copied and pasted on each module's `build.gradle`, including the `app` module. – Andrew T. Jul 13 '20 at 04:08