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

Distribute the library only as aar (not as jar) #91

Merged
merged 5 commits into from
Jan 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ installed to `~/.android-sdk`.
Building the Library
---------------------

You can build new `.jar` and `.aar` files as follows:
You can build new `.aar` files as follows:

```shell
./gradlew clean :build
```

Files are generated into `build/outputs/jar` and `build/outputs/aar`.
Files are generated into`build/outputs/aar`.


Running Tests
Expand Down Expand Up @@ -128,7 +128,7 @@ This process is a little ridiculous...
- Select the com.bugsnag closed repository
- Click the “release” button in the toolbar

### 4. Upload the .jar file to GitHub
### 4. Upload the .aar file to GitHub

- Create a "release" from your new tag on [GitHub Releases](https://github.com/bugsnag/bugsnag-android/releases)
- Upload the generated `.jar` file from `build/outputs/jar/bugsnag-android-x.y.z.jar` on the "edit tag" page for this release tag
- Upload the generated `.aar` file from `build/outputs/aar/bugsnag-android-release.aar` on the "edit tag" page for this release tag
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ Add `bugsnag-android` as a dependency in your `pom.xml`:
</dependency>
```

### Using a Jar

- Download the [latest bugsnag-android.jar](https://github.com/bugsnag/bugsnag-android/releases/latest)
- Place it in your Android app's `libs/` folder


Configuring Your AndroidManifest
--------------------------------

Expand All @@ -49,13 +43,12 @@ Configuring Your AndroidManifest
</application>
```

- Enable the `INTERNET`, `ACCESS_NETWORK_STATE` and `GET_TASKS` permissions:
- Recommended: Enable the `ACCESS_NETWORK_STATE` and `GET_TASKS` permissions:

```xml
<!-- Required: Used to deliver Bugsnag crash reports -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- Optional: To provide network connectivity information to Bugsnag -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<!-- Optional: To see which Activity was active at the time of a crash -->
<uses-permission android:name="android.permission.GET_TASKS"/>
```
Expand Down
27 changes: 1 addition & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,13 @@ android {
defaultConfig {
minSdkVersion 4
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}

buildTypes {
release {
minifyEnabled true
proguardFile 'proguard.txt'
}
consumerProguardFiles 'proguard.txt'
}

lintOptions {
disable 'DefaultLocale'
}
}

// Task to generate a .jar file
task jarRelease(type: Copy) {
def jarFile = POM_ARTIFACT_ID + '-' + VERSION_NAME + '.jar'

from 'build/intermediates/bundles/release/'
into 'build/outputs/jar'
include 'classes.jar'
rename('classes.jar', jarFile)

artifacts.add('archives', file('build/outputs/jar/' + jarFile));
}

// Generate .jar files when assembling release builds
tasks.whenTaskAdded { task ->
if (task.name == 'signArchives') {
task.dependsOn jarRelease
}
}

// Tasks to release the library to maven central
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
4 changes: 1 addition & 3 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ android {
buildTypes {

debug {
minifyEnabled true
proguardFile 'proguard.pro'
applicationIdSuffix ".debug"
}

release {
minifyEnabled true
proguardFile 'proguard.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.pro'
}
}

Expand Down
19 changes: 17 additions & 2 deletions example/proguard.pro
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
-keepattributes LineNumberTable,SourceFile
-dontoptimize
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in <android-sdk>/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
1 change: 0 additions & 1 deletion example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<meta-data android:name="com.bugsnag.android.API_KEY" android:value="066f5ad3590596f9aa8d601ea89af845"/>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
</manifest>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ POM_NAME=Bugsnag Android
POM_DESCRIPTION=Official Bugsnag notifier for Android applications
POM_URL=https://bugsnag.com
POM_ARTIFACT_ID=bugsnag-android
POM_PACKAGING=jar
POM_PACKAGING=aar

ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=21.1.1
Expand Down
23 changes: 5 additions & 18 deletions proguard.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
-dontobfuscate
-keeppackagenames com.bugsnag.**
-keepnames class com.bugsnag.**
-keepclassmembernames class com.bugsnag.** { *; }

-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keep public class * {
-keep public class com.bugsnag.** {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there some history behind keeping * instead of just com.bugsnag.* here, @snmaynard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current master the proguard rules are only used during the build of the library itself so only classes in this library are affected by -keep public class *.

With this PR the proguard rules aren't used during the build of library anymore but during the build of the app which includes the library. With the change above we make sure the rule still only affects the library and not the whole app

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that rings a bell. Thanks. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kattrali I wonder if the rule is needed at all when proguard runs during the app-build instead of during the library-build

public protected *;
}

-keep class com.bugsnag.android.Async {
static void run(java.lang.Runnable);
}

-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements java.io.Serializable {
-keepclassmembers class com.bugsnag.** implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
Expand Down
1 change: 0 additions & 1 deletion src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />

Expand Down
5 changes: 4 additions & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bugsnag.android"
android:versionCode="1"
android:versionName="1.0" >
android:versionName="1.0">

<!-- Required: Used to deliver Bugsnag crash reports -->
<uses-permission android:name="android.permission.INTERNET" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its nice to be able to guarantee this is enabled as well. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is one of the reasons for this PR 👍
see #50

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, just good to see it in action. :)


</manifest>