Skip to content

Commit 70d480e

Browse files
committed
[libaddressinput] add missing dependencies to gradle build files and update to Gradle 8.2.2
- An internal google update added dependencies only to internal google BUILD files and not the gradle.build file which breaks open source users of this codebase - Also upgrade the gradle version so modern Android studio users can actually build this
1 parent 779f0ec commit 70d480e

12 files changed

+431
-107
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ java/**/build/
44
android/build/
55
build/
66
common/build/
7+
.idea/
8+
local.properties

android/README.md

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,42 @@
22

33

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

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

1010

1111
## Prerequisite dependencies for using Gradle with Android
1212

13-
Android Studio: https://developer.android.com/sdk/index.html
14-
or
15-
Android SDK Tools: https://developer.android.com/sdk/index.html#Other
16-
17-
Set the ANDROID_HOME environment variable to the root of the SDK.
18-
19-
Install the following packages:
20-
* Tools/Android SDK Build-tools (Rev. 21.1.2)
21-
* Android 5.1 (API 22)
22-
* Extras/Android Support Library
13+
Android Studio: https://developer.android.com/sdk/index.html (recommended)
14+
- Check Tools > SDK Manager.
2315

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

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

3024

3125
## Building and Running
3226

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

36-
$ gradle build
31+
`gradlew build`
3732

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

41-
$ gradle connectedAndroidTest
36+
`gradlew connectedAndroidTest`
4237

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

45-
$ adb logcat
40+
`adb logcat`
4641

4742
# Integrating with Android Apps
4843

@@ -54,35 +49,35 @@ $ adb logcat
5449

5550
3. Build the widget and library via gradle:
5651

57-
`gradle build`
52+
`gradle build`
5853

5954
4. Copy the widget and the common libraries:
6055

61-
`cp android/build/outputs/aar/android-release.aar path/to/project/app/libs/`
56+
`cp android/build/outputs/aar/android-release.aar path/to/project/app/libs/`
6257

63-
`cp common/build/libs/common.jar path/to/project/app/libs/`
58+
`cp common/build/libs/common.jar path/to/project/app/libs/`
6459

65-
Note: Be sure top replace 'path/to/project' with the name of your project.
60+
Note: Be sure top replace 'path/to/project' with the name of your project.
6661

6762
5. Import both modules into your app.
6863

69-
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.
64+
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.
7065

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

73-
i. In activity_main.xml add:
68+
i. In activity_main.xml add:
7469

75-
```
70+
```xml
7671
<LinearLayout
7772
android:id="@+id/addresswidget"
7873
android:layout_width="match_parent"
7974
android:layout_height="match_parent"
8075
android:orientation="vertical"/>
8176
```
8277

83-
ii. In MainActivity.java add the following import statements:
78+
ii. In MainActivity.java add the following import statements:
8479

85-
```
80+
```java
8681
import android.view.ViewGroup;
8782

8883
import com.android.i18n.addressinput.AddressWidget;
@@ -91,12 +86,14 @@ $ adb logcat
9186
import com.google.i18n.addressinput.common.SimpleClientCacheManager;
9287
```
9388

94-
iii. Define the widget on the object scope
95-
96-
`private AddressWidget addressWidget;`
89+
iii. Define the widget on the object scope
9790

98-
iv. Add the widget to the ViewGroup
91+
```java
92+
private AddressWidget addressWidget;
9993
```
94+
95+
iv. Add the widget to the ViewGroup
96+
```java
10097
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.addresswidget);
10198
FormOptions defaultFormOptions = new FormOptions();
10299
ClientCacheManager cacheManager = new SimpleClientCacheManager();
@@ -105,7 +102,7 @@ $ adb logcat
105102

106103
Example:
107104

108-
```
105+
```java
109106
package com.example.google.widgetdemo;
110107

111108
import android.support.v7.app.AppCompatActivity;
@@ -131,4 +128,4 @@ public class MainActivity extends AppCompatActivity {
131128
this.addressWidget = new AddressWidget(this, viewGroup, defaultFormOptions, cacheManager);
132129
}
133130
}
134-
```
131+
```

android/build.gradle

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17-
buildscript {
18-
repositories {
19-
mavenCentral()
20-
mavenLocal()
21-
}
22-
dependencies {
23-
classpath 'com.android.tools.build:gradle:1.1.0'
24-
}
25-
}
26-
2717
apply plugin: 'com.android.library'
2818

2919
tasks.withType(JavaCompile) {
3020
options.encoding = 'UTF-8'
3121
}
3222

3323
dependencies {
34-
compile project(':common')
35-
compile 'com.google.android.gms:play-services-location:10.0.0'
36-
compile 'com.google.android.gms:play-services-places:9.2.0'
24+
api project(':common')
25+
implementation 'com.google.android.gms:play-services-location:10.0.0'
26+
implementation 'com.google.android.gms:play-services-places:9.2.0'
27+
implementation 'com.google.guava:guava-gwt:18.0'
3728
}
3829

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

android/src/androidTest/AndroidManifest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
android:versionCode="1"
55
android:versionName="1.0" >
66

7-
<uses-sdk
8-
android:minSdkVersion="14"
9-
android:targetSdkVersion="22" />
10-
117
<!-- Gradle generates an <instrumentation> block during the build process,
128
but in order to work with other build systems, that don't do that,
139
there must be such a block declared here. -->

android/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
android:versionCode="1"
44
android:versionName="1.0" >
55

6-
<uses-sdk
7-
android:minSdkVersion="9"
8-
android:targetSdkVersion="22" />
96
<application/>
107

118
</manifest>

build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,21 @@
1717
/*
1818
* Root Gradle file for Java address input widget (under "common" and "android")
1919
*/
20-
allprojects {
20+
buildscript {
2121
repositories {
2222
mavenCentral()
2323
mavenLocal()
24+
google()
25+
}
26+
dependencies {
27+
classpath 'com.android.tools.build:gradle:8.2.2'
2428
}
2529
}
30+
31+
allprojects {
32+
repositories {
33+
mavenCentral()
34+
mavenLocal()
35+
google()
36+
}
37+
}

common/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# Building and running tests
22

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

7-
http://tools.android.com/tech-docs/new-build-system
8-
http://www.gradle.org/
9-
6+
https://developer.android.com/build http://www.gradle.org/
107

118
## Prerequisite dependencies for using Gradle
129

13-
Gradle (latest version):
14-
https://services.gradle.org/distributions/gradle-2.3-bin.zip
15-
16-
Note: Additionally you must take care to avoid having multiple versions of
17-
Gradle on your path, as this can cause problems.
18-
10+
Use Android Studio to build packages and run tests. Alternatively, make use of
11+
the Gradle Wrapper Scripts: `gradlew` or `gradlew.bat`.
1912

2013
## Building and Running
2114

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

25-
$ gradle build
26-
$ gradle test
18+
##### On Linux / Unix / Mac
19+
20+
- `gradlew build`
21+
- `gradlew test`
22+
23+
##### On Windows
24+
25+
- `gradlew.bat build`
26+
- `gradlew.bat test`

common/build.gradle

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
buildscript {
18-
repositories {
19-
mavenCentral()
20-
mavenLocal()
21-
}
22-
dependencies {
23-
classpath 'com.android.tools.build:gradle:1.1.0'
24-
}
25-
}
17+
apply plugin: 'java-library'
2618

27-
apply plugin: 'java'
19+
sourceCompatibility = JavaVersion.VERSION_11
20+
targetCompatibility = JavaVersion.VERSION_11
2821

29-
sourceCompatibility = '1.7'
30-
targetCompatibility = '1.7'
31-
32-
tasks.withType(JavaCompile) {
22+
tasks.withType(JavaCompile).configureEach {
3323
options.encoding = 'UTF-8'
3424
}
3525

@@ -55,13 +45,21 @@ test {
5545
// }
5646
}
5747

48+
repositories {
49+
google()
50+
mavenLocal()
51+
mavenCentral()
52+
}
53+
5854
dependencies {
59-
compile 'com.google.guava:guava-gwt:18.0'
55+
api 'com.google.errorprone:error_prone_annotations:2.18.0'
56+
api 'org.jspecify:jspecify:0.2.0'
57+
implementation 'com.google.guava:guava-gwt:18.0'
6058
/* Note that gradle will warn about this not being the same version as *
6159
* the Android JSON library (but will not compile if it's removed). */
62-
compile 'org.json:json:20090211'
63-
testCompile 'junit:junit:4.11'
64-
testCompile 'com.google.truth:truth:0.25'
65-
testCompile 'org.mockito:mockito-core:1.9.5'
60+
implementation 'org.json:json:20090211'
61+
testImplementation 'junit:junit:4.11'
62+
testImplementation 'com.google.truth:truth:0.25'
63+
testImplementation 'org.mockito:mockito-core:5.11.0'
6664
}
6765

gradle/wrapper/gradle-wrapper.jar

61.9 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)