Skip to content

Commit

Permalink
Add x86_64 arch for android platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
domchen committed Dec 6, 2023
1 parent 061fa3f commit ecd01ee
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 91 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ elseif (ANDROID OR IOS)
endif ()
else ()
if (MSVC)
set(ARCH ${MSVC_C_ARCHITECTURE_ID})
string(TOLOWER ${MSVC_C_ARCHITECTURE_ID} ARCH)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR $CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
set(ARCH x64)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
Expand Down
71 changes: 38 additions & 33 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 33
buildToolsVersion '33.0.2'
defaultConfig {
applicationId "org.libpag.pagviewer"
minSdkVersion 18
targetSdkVersion 27
minSdkVersion 19
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
if (project.hasProperty("arm64-only")) {
abiFilters.add("arm64-v8a")
} else {
abiFilters.add("armeabi-v7a")
abiFilters.add("arm64-v8a")
abiFilters.add("x86_64")
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', project(':ffavc').file('proguard-rules.pro')
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', project(':ffavc').file('proguard-rules.pro')
}
}

Expand All @@ -30,65 +40,60 @@ android {
main.assets.srcDirs = ['../../assets']
}

repositories {
flatDir {
dirs 'libs'
}
}
namespace 'libpag.pagviewer'
}

project.afterEvaluate {
// 如果使用自动拷贝功能,需要保证NDK是16,否则会生成没有经过strip的包
transformNativeLibsWithMergeJniLibsForRelease.doLast {
mergeReleaseNativeLibs.doLast {
delete {
delete 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/merged_native_libs/release/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/merged_native_libs/release/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/merged_native_libs/release/out/lib/armeabi'
include '*.so'
}
}
transformNativeLibsWithStripDebugSymbolForRelease.doLast {
stripReleaseDebugSymbols.doLast {
delete {
delete 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/stripped_native_libs/release/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/stripped_native_libs/release/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/stripped_native_libs/release/out/lib/armeabi'
include '*.so'
}
}
// 此处为了方便debug,保留debug版本armeabi的拷贝,方便源码接入时候的调试
transformNativeLibsWithMergeJniLibsForDebug.doLast {
mergeDebugNativeLibs.doLast {
delete {
delete 'build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/merged_native_libs/debug/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/merged_native_libs/debug/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/merged_native_libs/debug/out/lib/armeabi'
include '*.so'
}
}
transformNativeLibsWithStripDebugSymbolForDebug.doLast {
stripDebugDebugSymbols.doLast {
delete {
delete 'build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/stripped_native_libs/debug/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/stripped_native_libs/debug/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/stripped_native_libs/debug/out/lib/armeabi'
include '*.so'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'libpag_release_3.2.8.3', ext: 'aar')
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation 'com.tencent.tav:libpag:4.3.33-noffavc'
implementation "androidx.appcompat:appcompat:$appcompatVersion"
debugImplementation project(':ffavc')
releaseImplementation project(':ffavc')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}

configurations.all {
Expand Down
14 changes: 10 additions & 4 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="libpag.pagviewer">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
tools:ignore="ProtectedPermissions" />

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity android:name=".MainActivity">
<activity
android:name="libpag.pagviewer.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
5 changes: 3 additions & 2 deletions android/app/src/main/java/libpag/pagviewer/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package libpag.pagviewer;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import org.ffavc.DecoderFactory;
import org.libpag.PAGFile;
import org.libpag.PAGView;
import org.libpag.VideoDecoder;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -21,7 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {
final PAGView pagView = (PAGView) findViewById(R.id.pagView);
PAGFile pagFile = PAGFile.Load(getAssets(), "particle_video.pag");
pagView.setRepeatCount(-1);
pagView.setFile(pagFile);
pagView.setComposition(pagFile);
pagView.play();
}
}
22 changes: 10 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
kotlin_version = '1.3.50'
kotlinVersion = '1.6.21'
supportLibVersion = '28.0.0'
junitVersion="4.12"
agpVersion = '8.0.0'
appcompatVersion = '1.4.2' // after this version, compileSdkVersion must large than 31
}
repositories {
maven {
url "https://mirrors.tencent.com/repository/maven/tencent_public"
}
maven {
url "https://mirrors.tencent.com/repository/maven/tencent_public_snapshots"
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://mirrors.tencent.com/nexus/repository/maven-public"
}
// jcenter()

google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$agpVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
60 changes: 35 additions & 25 deletions android/ffavc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileSdkVersion 33
buildToolsVersion '33.0.2'
ndkVersion "19.2.5345600"

defaultConfig {
minSdkVersion 18
targetSdkVersion 28
minSdkVersion 19
targetSdkVersion 33
versionCode 1
versionName "1.0"

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

externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_static"
}
}

ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
if (project.hasProperty("arm64-only")) {
abiFilters.add("arm64-v8a")
} else {
abiFilters.add("armeabi-v7a")
abiFilters.add("arm64-v8a")
abiFilters.add("x86_64")
}
}
}

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

externalNativeBuild {
cmake {
path '../../CMakeLists.txt'
version = "3.22.1"
}
}

namespace 'org.ffavc'
}

dependencies {
Expand All @@ -47,45 +58,44 @@ dependencies {
}

project.afterEvaluate {
// 如果使用自动拷贝功能,需要保证NDK是16,否则会生成没有经过strip的包
transformNativeLibsWithMergeJniLibsForRelease.doLast {
mergeReleaseNativeLibs.doLast {
delete {
delete 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/merged_native_libs/release/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/merged_native_libs/release/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/merged_native_libs/release/out/lib/armeabi'
include '*.so'
}
}
transformNativeLibsWithStripDebugSymbolForRelease.doLast {
stripReleaseDebugSymbols.doLast {
delete {
delete 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/stripped_native_libs/release/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/stripped_native_libs/release/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/stripped_native_libs/release/out/lib/armeabi'
include '*.so'
}
}
// 此处为了方便debug,保留debug版本armeabi的拷贝,方便源码接入时候的调试
transformNativeLibsWithMergeJniLibsForDebug.doLast {
mergeDebugNativeLibs.doLast {
delete {
delete 'build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/merged_native_libs/debug/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/merged_native_libs/debug/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/merged_native_libs/debug/out/lib/armeabi'
include '*.so'
}
}
transformNativeLibsWithStripDebugSymbolForDebug.doLast {
stripDebugDebugSymbols.doLast {
delete {
delete 'build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi'
delete project.getBuildDir().path + '/intermediates/stripped_native_libs/debug/out/lib/armeabi'
}
copy {
from 'build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi'
from project.getBuildDir().path + '/intermediates/stripped_native_libs/debug/out/lib/armeabi-v7a'
into project.getBuildDir().path + '/intermediates/stripped_native_libs/debug/out/lib/armeabi'
include '*.so'
}
}
Expand Down
25 changes: 12 additions & 13 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true


#Wed Dec 06 23:39:49 CST 2023
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4608M

android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.native.buildOutput=verbose
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Dec 06 23:21:17 CST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.tencent.com/gradle/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit ecd01ee

Please sign in to comment.