Skip to content

Commit

Permalink
Merge pull request #1128 from rhomobile/fixed-multidex
Browse files Browse the repository at this point in the history
Fixed multidex
  • Loading branch information
alex-epifanoff committed Apr 10, 2024
2 parents 1f942e7 + 97a2f17 commit 309b486
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion platform/android/build/android.rake
Expand Up @@ -3031,7 +3031,7 @@ namespace "package" do
jarsForDX << File.join(proguardPostBuild, "classes-processed.jar")
end

unless AndroidTools::DexBuilder.instance.build( jarsForDX, "#{File.join($bindir,'classes.dex')}")
unless AndroidTools::DexBuilder.instance.build( jarsForDX, "#{File.join($bindir,'classes.dex')}", $min_sdk_level)
raise "Error running DEX builder"
end

Expand Down
15 changes: 12 additions & 3 deletions platform/android/build/android_tools.rb
Expand Up @@ -31,6 +31,7 @@

require 'pp'
require 'open3'
require 'find'

module AndroidTools

Expand Down Expand Up @@ -978,9 +979,17 @@ def apk_build(sdk, apk_name, res_name, dex_name, debug)
puts "Building APK file..."

#just put dex file to a copy of already prepared intermediate APK
cp res_name, apk_name
params = [ '-uf', apk_name, '-C', File.dirname(dex_name), File.basename(dex_name) ]
Jake.run( @@jarbin, params)
cp res_name, apk_name
dex_files = []

Find.find(File.dirname(dex_name)) do |path|
dex_files << path if path.end_with?('.dex')
end

dex_files.each do |dex_file|
params = [ '-uf', apk_name, '-C', File.dirname(dex_file), File.basename(dex_file)]
Jake.run( @@jarbin, params)
end

unless $?.success?
raise 'Error building APK file'
Expand Down
10 changes: 6 additions & 4 deletions platform/android/build/dex_builder.rb
Expand Up @@ -9,10 +9,10 @@ class DexBuilder

attr_accessor :logger, :sdk_path, :build_tools_path, :androidplatform, :javabin

def build( jarlist = [], outdex )
def build( jarlist = [], outdex, min_sdk )
tools_path = detect_tools_path

bin,args = build_cmd_line(tools_path, jarlist, outdex)
bin,args = build_cmd_line(tools_path, jarlist, outdex, min_sdk)

@logger.debug "BIN: #{bin}, ARGS: #{args}"
return false unless bin
Expand Down Expand Up @@ -41,7 +41,7 @@ def detect_tools_path
path
end

def build_cmd_line(tools_path, jarlist, outdex)
def build_cmd_line(tools_path, jarlist, outdex, min_sdk)

@logger.error( "DEX builder: path to build tools not set" ) unless @build_tools_path

Expand Down Expand Up @@ -75,7 +75,9 @@ def build_cmd_line(tools_path, jarlist, outdex)
args << "#{File.dirname(outdex)}"
#args << '--no-desugaring'
args.concat jarlist

args << '--min-api'
args << min_sdk.to_s

return d8, args
else
@logger.error( "Can't find proper DEX builder in the build tools")
Expand Down

0 comments on commit 309b486

Please sign in to comment.