8000 Improve Android AAR support by mortend · Pull Request #258 · fuse-open/uno · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve Android AAR support #258

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

Merged
merged 6 commits into from
Nov 25, 2019
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
28 changes: 21 additions & 7 deletions lib/UnoCore/Targets/Android/Android.uxl
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,32 @@
<Set Activity.BaseClass="androidx.appcompat.app.AppCompatActivity" />
<Set Activity.Name="@(Project.Android.Activity || Project.Name:Identifier)" />
<Set Activity.Package="@(Project.Android.Package || 'com.apps.@(Project.Name:QIdentifier:ToLower)')" />
<Set Build.Configuration="@('!@(DEBUG:Defined) && @(Project.Android.Key.Store:IsSet)':Test('Release', 'Debug'))" />
<Set APK.BuildName="app/build/outputs/apk/@(Build.Configuration:ToLower)/app-@(Build.Configuration:ToLower).apk" />
<Set APK.Gradle.Task="assemble@(Build.Configuration)" />
<Set Bundle.BuildName="app/build/outputs/bundle/@(Build.Configuration:ToLower)/app.aab" />
<Set Bundle.Gradle.Task="bundle@(Build.Configuration)" />

<!-- Build configuration -->

<Set Condition="LIBRARY" Build.Configuration="@('!@(DEBUG:Defined)':Test('Release', 'Debug'))" />
<Set Condition="!LIBRARY" Build.Configuration="@('!@(DEBUG:Defined) && @(Project.Android.Key.Store:IsSet)':Test('Release', 'Debug'))" />

<Set Gradle.AssembleTask="assemble@(Build.Configuration)" />
<Set Gradle.BundleTask="bundle@(Build.Configuration)" />

<Set Outputs.AAR="app/build/outputs/aar/app-@(Build.Configuration:ToLower).aar" />
<Set Outputs.APK="app/build/outputs/apk/@(Build.Configuration:ToLower)/app-@(Build.Configuration:ToLower).apk" />
<Set Outputs.Bundle="app/build/outputs/bundle/@(Build.Configuration:ToLower)/app.aab" />

<!-- Run-time properties -->

<Set Runtime.CatchCppExceptions=2 />
<Set Runtime.CppMainLoop="Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN" />
<Set Runtime.DebugPauseMilliseconds=0 />
<Set Runtime.KillActivityOnDestroy=true />
<Set Runtime.SeperateUnoThread="AppRuntimeSettings.CppMainLoop" />
<Set Product="@(Project.Name).apk" />
<Set Bundle="@(Project.Name).aab" />

<!-- Output files -->

<Set Condition="LIBRARY" Product="@(Project.Name).aar" />
<Set Condition="!LIBRARY" Product="@(Project.Name).apk" />
<Set Condition="!LIBRARY" Bundle="@(Project.Name).aab" />

<!-- Deprecated properties -->

Expand Down
16 changes: 11 additions & 5 deletions lib/UnoCore/Targets/Android/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ for /D %%D in ("@(SDK.Directory:NativePath)\cmake\*") do (
)

:BUILD
call gradlew @(APK.Gradle.Task) %* || goto ERROR
copy /Y @(APK.BuildName:QuoteSpace:Replace('/', '\\')) @(Product:QuoteSpace) || goto ERROR
#if !@(DEBUG:Defined)
call gradlew @(Bundle.Gradle.Task) %* || goto ERROR
copy /Y @(Bundle.BuildName:QuoteSpace:Replace('/', '\\')) @(Bundle:QuoteSpace) || goto ERROR
call gradlew @(Gradle.AssembleTask) %* || goto ERROR

#if @(LIBRARY:Defined)
copy /Y @(Outputs.AAR:QuoteSpace:Replace('/', '\\')) @(Product:QuoteSpace) || goto ERROR
#else
copy /Y @(Outputs.APK:QuoteSpace:Replace('/', '\\')) @(Product:QuoteSpace) || goto ERROR
# if !@(DEBUG:Defined)
call gradlew @(Gradle.BundleTask) %* || goto ERROR
copy /Y @(Outputs.Bundle:QuoteSpace:Replace('/', '\\')) @(Bundle:QuoteSpace) || goto ERROR
# endif
#endif

popd && exit /b 0

:ERROR
Expand Down
18 changes: 9 additions & 9 deletions lib/UnoCore/Targets/Android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ exit 1
export JAVA_HOME="@(JDK.Directory)"
#endif

./gradlew @(APK.Gradle.Task) "$@"
#if !@(DEBUG:Defined)
./gradlew @(Bundle.Gradle.Task)
#endif
./gradlew @(Gradle.AssembleTask) "$@"

#if !@(LIBRARY:Defined)
ln -sf @(APK.BuildName:QuoteSpace) @(Product:QuoteSpace)
#if !@(DEBUG:Defined)
ln -sf @(Bundle.BuildName:QuoteSpace) @(Bundle:QuoteSpace)
#endif
#if @(LIBRARY:Defined)
ln -sf @(Outputs.AAR:QuoteSpace) @(Product:QuoteSpace)
#else
ln -sf @(Outputs.APK:QuoteSpace) @(Product:QuoteSpace)
# if !@(DEBUG:Defined)
./gradlew @(Gradle.BundleTask)
ln -sf @(Outputs.Bundle:QuoteSpace) @(Bundle:QuoteSpace)
# endif
#endif
5 changes: 5 additions & 0 deletions lib/UnoCore/Targets/Android/run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if "%1" == "debug" (
exit /b %ERRORLEVEL%
)

#if @(LIBRARY:Defined)
echo ERROR: @(Product) is a library and cannot be run directly.
exit /b 1
#else
if "%1" == "uninstall" (
echo Uninstalling @(Activity.Package)
@(Uno) adb uninstall @(Activity.Package)
Expand All @@ -24,3 +28,4 @@ if "%1" == "uninstall" (
--sym-dir="%~dp0src\main\.uno" ^
%*
exit /b %ERRORLEVEL%
#endif
5 changes: 5 additions & 0 deletions lib/UnoCore/Targets/Android/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ uninstall)
;;
esac

#if @(LIBRARY:Defined)
echo "ERROR: @(Product) is a library and cannot be run directly." >&2
exit 1
#else
@(Uno) launch-apk "@(Product)" \
--package=@(Activity.Package) \
--activity=@(Activity.Name) \
--sym-dir="app/src/main/.uno" \
"$@"
#endif
16 changes: 11 additions & 5 deletions src/engine/Uno.Build.Targets/Android/AndroidBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ public override void Configure(ICompiler compiler)

public override void DeleteOutdated(Disk disk, IEnvironment env)
{
// Remove previously built APK to avoid Android caching issues
var apk = env.GetString("APK.BuildName");
if (apk.IsValidPath())
disk.DeleteFile(env.Combine(apk.UnixToNative()));
// Remove previously built AAR, APK and Bundle to avoid caching issues.
foreach (var output in new[] {
env.GetString("Outputs.AAR"),
env.GetString("Outputs.APK"),
env.GetString("Outputs.Bundle")
})
{
if (output.IsValidPath())
disk.DeleteFile(env.Combine(output.UnixToNative()));
}

// Delete old Java files so Gradle won't try to build them
// Delete old Java files so Gradle won't try to build them.
disk.DeleteOutdatedFiles(env.GetOutputPath("Java.SourceDirectory"));
}
}
Expand Down
0