[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libaddressinput] add missing dependencies to gradle build files and update to Gradle 8.2.2 #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ java/**/build/
android/build/
build/
common/build/
.idea/
local.properties
67 changes: 32 additions & 35 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,42 @@


The easiest way to build libaddressinput for Android and run all the tests is
using the Gradle project automation tool:
to use Gradle:

http://tools.android.com/tech-docs/new-build-system
https://developer.android.com/build
http://www.gradle.org/


## Prerequisite dependencies for using Gradle with Android

Android Studio: https://developer.android.com/sdk/index.html
or
Android SDK Tools: https://developer.android.com/sdk/index.html#Other

Set the ANDROID_HOME environment variable to the root of the SDK.

Install the following packages:
* Tools/Android SDK Build-tools (Rev. 21.1.2)
* Android 5.1 (API 22)
* Extras/Android Support Library
Android Studio: https://developer.android.com/sdk/index.html (recommended)
- Check Tools > SDK Manager.

Gradle (latest version):
https://services.gradle.org/distributions/gradle-2.3-bin.zip
Android SDK Tools: https://developer.android.com/sdk/index.html#Other
- Set the ANDROID_HOME environment variable to the root of the SDK.

Note: Additionally you must take care to avoid having multiple versions of
Gradle on your path, as this can cause problems.
Ensure the following packages are installed:
- Tools/Android SDK Platform-tools (Rev. 35.0.1)
- Android 14 (API 34)
- Extras/Android Support Library


## Building and Running

After installing all the prerequisites, check that everything is working by
running:
building the package and running the tests in Android Studio. Alternatively, the
following can be run by command line:

$ gradle build
`gradlew build`

With an Android emulator running or an Android device connected, the following
command line then builds the library and runs the tests:

$ gradle connectedAndroidTest
`gradlew connectedAndroidTest`

The test runner logs to the system log, which can be viewed using logcat:

$ adb logcat
`adb logcat`

# Integrating with Android Apps

Expand All @@ -54,35 +49,35 @@ $ adb logcat

3. Build the widget and library via gradle:

`gradle build`
`gradle build`

4. Copy the widget and the common libraries:

`cp android/build/outputs/aar/android-release.aar path/to/project/app/libs/`
`cp android/build/outputs/aar/android-release.aar path/to/project/app/libs/`

`cp common/build/libs/common.jar path/to/project/app/libs/`
`cp common/build/libs/common.jar path/to/project/app/libs/`

Note: Be sure top replace 'path/to/project' with the name of your project.
Note: Be sure top replace 'path/to/project' with the name of your project.

5. Import both modules into your app.

Note: If you use Android Studio, check out the [user guide](https://developer.android.com/studio/projects/android-library.html#AddDependency) and follow the instructions under 'Add your library as a dependency'. Be sure to add *both* modules as dependencies of the app.
Note: If you use Android Studio, check out the [user guide](https://developer.android.com/studio/projects/android-library.html#AddDependency) and follow the instructions under 'Add your library as a dependency'. Be sure to add *both* modules as dependencies of the app.

6. Add the widget to your app. Note: This Assumes a default empty project configuration:

i. In activity_main.xml add:
i. In activity_main.xml add:

```
```xml
<LinearLayout
android:id="@+id/addresswidget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
```

ii. In MainActivity.java add the following import statements:
ii. In MainActivity.java add the following import statements:

```
```java
import android.view.ViewGroup;

import com.android.i18n.addressinput.AddressWidget;
Expand All @@ -91,12 +86,14 @@ $ adb logcat
import com.google.i18n.addressinput.common.SimpleClientCacheManager;
```

iii. Define the widget on the object scope

`private AddressWidget addressWidget;`
iii. Define the widget on the object scope

iv. Add the widget to the ViewGroup
```java
private AddressWidget addressWidget;
```

iv. Add the widget to the ViewGroup
```java
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.addresswidget);
FormOptions defaultFormOptions = new FormOptions();
ClientCacheManager cacheManager = new SimpleClientCacheManager();
Expand All @@ -105,7 +102,7 @@ $ adb logcat

Example:

```
```java
package com.example.google.widgetdemo;

import android.support.v7.app.AppCompatActivity;
Expand All @@ -131,4 +128,4 @@ public class MainActivity extends AppCompatActivity {
this.addressWidget = new AddressWidget(this, viewGroup, defaultFormOptions, cacheManager);
}
}
```
```
41 changes: 8 additions & 33 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,28 @@
* limitations under the License.
*/

buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}

apply plugin: 'com.android.library'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

dependencies {
compile project(':common')
compile 'com.google.android.gms:play-services-location:10.0.0'
compile 'com.google.android.gms:play-services-places:9.2.0'
api project(':common')
implementation 'com.google.android.gms:play-services-location:10.0.0'
implementation 'com.google.android.gms:play-services-places:9.2.0'
implementation 'com.google.guava:guava-gwt:18.0'
}

android {
/*
* If these are modified, update the README to reflect the new versions and
* update any related settings in the AdroidManifest.xml file.
*
* NOTE: Because the 'buildToolsVersion' directive only matches an exact
* release (rather than allowing wildcards) and Android remove older
* versions of the build tools very soon after a new revision is made
* available, we must never use the lastest major version of the build
* tools here (because it will quickly be superceded and become unavailable
* to anyone using a fresh install of the SDK). The "final" release of the
* previous major version remains available for much longer however, so as
* a workaround we always use that.
*
* So when the build tools version 23.0.0 is released, the buildToolsVersion
* below should be bumped to the last released version of the 22.x.x series.
*
* The obvious way to fix this would be allow wildcards (ie, "22.+") but
* Android have explicitly said that they won't do this.
* If these are modified, update the README to reflect the new versions.
*/
compileSdkVersion 22
buildToolsVersion '21.1.2'
namespace "com.android.i18n.addressinput"
compileSdk 34
defaultConfig {
minSdkVersion 17
targetSdkVersion 22
targetSdkVersion 34
}
}

4 changes: 0 additions & 4 deletions android/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />

<!-- Gradle generates an <instrumentation> block during the build process,
but in order to work with other build systems, that don't do that,
there must be such a block declared here. -->
Expand Down
3 changes: 0 additions & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="22" />
<application/>

</manifest>
14 changes: 13 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@
/*
* Root Gradle file for Java address input widget (under "common" and "android")
*/
allprojects {
buildscript {
repositories {
mavenCentral()
mavenLocal()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

allprojects {
repositories {
mavenCentral()
mavenLocal()
google()
}
}
24 changes: 12 additions & 12 deletions common/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Building and running tests


The common (non-UI) parts of libaddressinput are built and run using the Gradle
project automation tool:

http://tools.android.com/tech-docs/new-build-system
http://www.gradle.org/

https://developer.android.com/build http://www.gradle.org/

## Prerequisite dependencies for using Gradle

Gradle (latest version):
https://services.gradle.org/distributions/gradle-2.3-bin.zip

Note: Additionally you must take care to avoid having multiple versions of
Gradle on your path, as this can cause problems.

Use Android Studio to build packages and run tests. Alternatively, make use of
the Gradle Wrapper Scripts: `gradlew` or `gradlew.bat`.

## Building and Running

After installing all the prerequisites, check that everything is working by
running:

$ gradle build
$ gradle test
##### On Linux / Unix / Mac

- `gradlew build`
- `gradlew test`

##### On Windows

- `gradlew.bat build`
- `gradlew.bat test`
36 changes: 17 additions & 19 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@
* limitations under the License.
*/

buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'java-library'

apply plugin: 'java'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

Expand All @@ -55,13 +45,21 @@ test {
// }
}

repositories {
google()
mavenLocal()
mavenCentral()
}

dependencies {
compile 'com.google.guava:guava-gwt:18.0'
api 'com.google.errorprone:error_prone_annotations:2.18.0'
api 'org.jspecify:jspecify:0.2.0'
implementation 'com.google.guava:guava-gwt:18.0'
/* Note that gradle will warn about this not being the same version as *
* the Android JSON library (but will not compile if it's removed). */
compile 'org.json:json:20090211'
testCompile 'junit:junit:4.11'
testCompile 'com.google.truth:truth:0.25'
testCompile 'org.mockito:mockito-core:1.9.5'
implementation 'org.json:json:20090211'
testImplementation 'junit:junit:4.11'
testImplementation 'com.google.truth:truth:0.25'
testImplementation 'org.mockito:mockito-core:5.11.0'
}

Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading