2

I want to make a library which uses SharedPreferences. Now to do so I'd need to have android.jar available to me. But, as my project will never run stand-alone, I highly doubt making it a full-blown android application will be the right way to go.

Right now I've got the following build.gradle:

apply plugin: 'eclipse'
apply plugin: 'maven'

buildscript {
    repositories { 
        jcenter()
    }


    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}


apply plugin: 'android-library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    repositories {
        mavenCentral()
    }

    dependencies {
      compile fileTree(dir: 'libs', include: '*.jar')
      testCompile 'junit:junit:4.12'
      testCompile 'org.slf4j:slf4j-simple:1.6.1'

    }
}

But also the following error:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring root project 'NetworkSynchronizer'.

    java.io.FileNotFoundException: D:\Users\Beheerder\git\NetworkSynchronizer\src\main\AndroidManifest.xml (The system cannot find the file specified)

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Is this the right way to go, should I just add an AndroidManifest.xml, or how else should I handle this?

Daniël van den Berg
  • 2,197
  • 1
  • 20
  • 45

1 Answers1

0

Add AndroidManifest to your library:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="<YOUR_PACKAGE_HERE>">

    <application android:allowBackup="true"
             android:label="@string/app_name">

    </application>
</manifest>

Because you're using android-library plugin, thats absolutely normal. And you'll get @aar file in the end, not jar. Good luck!

lewkka
  • 1,019
  • 15
  • 25
  • For jar library you can read [here](http://stackoverflow.com/questions/17218295/android-gradle-build-system-create-jar-not-library) – lewkka Oct 30 '15 at 10:20