ngageoint / geopackage-android

GeoPackage Android Library
http://ngageoint.github.io/geopackage-android
MIT License
94 stars 33 forks source link

Compatible: Manifest merge conflict and androidx support #54

Closed alx696 closed 5 years ago

alx696 commented 5 years ago

Version Information:

Problem

  1. Manifest merge conflict. Add 'tools:replace' not work. Can not build.
  2. com.android.support and androidx.appcompat conflict. Can not build.

Output:

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86
    is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:11:3-23:17 to override.

ERROR: Manifest merger failed with multiple errors, see logs
org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures.
...

Steps to Reproduce:

build.gradle
  implementation 'androidx.appcompat:appcompat:1.0.2'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

  implementation 'mil.nga.geopackage:geopackage-android:3.1.0'
sync gradle

Relevant Code:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 28
  defaultConfig {
    applicationId "red.lilu.app.maptest"
    minSdkVersion 21
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
  }
  // Add below lines to set compatibility with Java 8 language features for an Android app module.
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'androidx.appcompat:appcompat:1.0.2'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

  implementation 'mil.nga.geopackage:geopackage-android:3.1.0'
//  implementation project(":geopackage")
  implementation 'org.osmdroid:osmdroid-android:6.1.0-SNAPSHOT:debug@aar'

  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test.ext:junit:1.1.0'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

Suggest

Clean up sqlite aar

Manifest merge conflict cause by sqlite aar, remove all tags.

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

to:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.sqlite.database" />
Empty geopackage-android's AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="mil.nga.geopackage" />

Module library without ui not need tags any more. I remove them, works fine.

androidx support

Add tools:replace="android:appComponentFactory" to main Manifests not work, can not build.

Change com.android.support:support-v13:28.0.0 to androidx.appcompat:appcompat:1.0.2 will work, but will affect old users...

Last

  1. Manifest merge conflict need to solve as soon as possible. Can not build!
  2. Anyone use androidx need to build from source now. Blow is my geopackage-android build.gradle:
apply plugin: 'com.android.library'

android {
  compileSdkVersion 28

  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }

  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
  }

}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])

  implementation 'androidx.appcompat:appcompat:1.0.2'
  //drop mil.nga:sqlite-android:3240000
  implementation project(':sqlite-android')
  implementation'com.j256.ormlite:ormlite-android:5.1'
  implementation 'ar.com.hjg:pngj:2.1.0'
  implementation 'mil.nga:tiff:2.0.0'
  implementation 'mil.nga.sf:sf-geojson:2.0.0'
  api 'mil.nga.geopackage:geopackage-core:3.1.0'

  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.2'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

You can build a library module first, then copy src in.

I changed the sqlite library. I download https://sqlite.org/2019/sqlite-android-3270200.aar. So i can change AndroidManifest.xml easily(drag out, modify, drop in).

bosborn commented 5 years ago

Upgraded the develop branch to use AndroidX for the upcoming 3.2.0 release.

Also upgraded the android-map library and mapcache app develop branches. Both worked fine with AndroidX updates to this library.

The sqlite-android aar is intentionally included as a repository api for automatic and consistent RTree support. Requiring a manual download of this library is something we want to avoid. The Android Manifest replaces the default allow backup setting and enables cleartext traffic for downloading http GeoPackage files.

alx696 commented 5 years ago

After change to androidx.appcompat, add tools:replace not work. So, i remove them all.

I will try after 3.2.0 release. If ok, i will close this issues.

bosborn commented 5 years ago

You can fork this repository and checkout the develop branch if you'd like to try without waiting.

alx696 commented 5 years ago

@bosborn I changed my way of using GeoPackage. ArcGIS, Google Map SDK and Osmdroid do not have a strong support of GeoPackage(can not custom sytle or any thing else). And dependent library sqlite have some very bad tag been merged to AndroidManifest.xml. For example: android.permission.WRITE_EXTERNAL_STORAGE, because it is target api is 1.0...

So, i just use mil.nga.geopackage:geopackage-core:3.1.0 to transform Geometry data. I saved (Point, LineString) with GeoPackage Geometry, but used Room Persistence Library . I think the most wanted feature is:

  1. Create a GeoPackage database;
  2. Management data in GeoPackage database;
  3. Query data from GeoPackage database;
  4. Tools for transform tiles from(to) ZXY.

I have try lot to use full GeoPackage, but can not find any document or example how to use tiles... I know the zoom, x, y, but how to get the tile? Finally i chose to use osmdroid sqlite. It is easy to use and understand. I can easily dev a tool to produce tile and show them.

Don't spend a lot of time on the ui features. GeoPackage is Encoding Standard and Datastore.

bosborn commented 5 years ago

New versions of these libraries are being released this week in case you still want to try. You can certainly use geopackage-core directly, but the intent is to be used through geopackage-java, geopackage-android, or geopackage-android-map. These libraries handle all the creation, management, query, and XYZ transforms for you.

The versions releasing this week also include support for the NGA extensions: Feature Style and Contents Id. The feature extension supports styles and icons for feature geometries and defaults for feature tables. Official OGC GeoPackage style support is still a ways out. QGIS has an OWS extension, but we are waiting for an official style adoption from OGC.

Android usually lets you override any manifest settings for your own project.

Retrieving a tile from a XYZ in a GeoPackage is of course possible, yet not a trivial operation. See: in android and in java

bosborn commented 5 years ago

New Java and Android versions of these libraries have been released: