23
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidStudio で Unity に組み込む用の *.aar をつくるときに classes.jar を除外する

Posted at

libs ディレクトリに Unity のライブラリ classes.jar ファイルが追加されている前提。

メインモジュール( app とか )内の build.gradle に以下の内容を追加する。

build.gradle
android.libraryVariants.all { variant ->
	variant.outputs.each { output ->
		output.packageLibrary.exclude('libs/classes.jar')
	}
}

上記の項目は、android ライブラリとしてビルドするようになっていないとエラーになるので注意。
最終的な build.gradle は以下のようになる。
android.libraryVariants.all 以外の部分は各プロジェクトで変わってくると思うのであくまで参考で。

build.gradle
apply plugin: 'com.android.library'

android {
	compileSdkVersion 22
	buildToolsVersion "22.0.1"
	
	defaultConfig {
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
	}
	buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
	}
}

android.libraryVariants.all { variant ->
	variant.outputs.each { output ->
		output.packageLibrary.exclude('libs/classes.jar')
	}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
}

参考ページ

23
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?