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

support define applicationId in build.gradle #36

Merged
merged 4 commits into from
Aug 21, 2015
Merged
Changes from 1 commit
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
Prev Previous commit
support define applicationId in build.gradle
  • Loading branch information
Timeszoro committed Aug 20, 2015
commit 87859be725ad7aec3708d3a26e61d24b5dbe9b66
40 changes: 32 additions & 8 deletions cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@ def package_name(dir):
for pn in re.findall('package=\"([\w\d_\.]+)\"', data):
return pn

def package_name_fromapk(dir,sdkdir):
apkpath = os.path.join(dir,'build','outputs','apk')
#Get the lastmodified *.apk file
lastModified = 0
maxt = 0
maxd = None
for dirpath, dirnames, files in os.walk(apkpath):
for fn in files:
if fn.endswith('.apk') and not fn.endswith('-unaligned.apk'):
lastModified = os.path.getmtime(os.path.join(dirpath, fn))
if lastModified > maxt:
maxt = lastModified
maxd = os.path.join(dirpath, fn)
#Get the package name from maxd
aaptpath = get_aapt(sdkdir)
if not aaptpath:
print('aapt not found in %s/build-tools'%sdkdir)
exit(1)
aaptargs = [aaptpath, 'dump','badging', maxd]
aaptargsstr = ' '.join(aaptargs)
cmdout = os.popen(aaptargsstr).read()
for pn in re.findall('package: name=\'([^\']*)\'',cmdout):
return pn

def isResName(name):
if name=='drawable' or name.startswith('drawable-'):
return 2
Expand Down Expand Up @@ -512,20 +536,20 @@ def get_pre_dexed_lib(list):

projlist = [i for i in list_projects(dir) if is_launchable_project(i)]

if not projlist:
print('no valid android project found in '+os.path.abspath(dir))
exit(1)

pnlist = [package_name(i) for i in projlist]
portlist = [0 for i in pnlist]
stlist = [-1 for i in pnlist]

if not sdkdir:
sdkdir = get_android_sdk(dir)
if not sdkdir:
print('android sdk not found, specify in local.properties or export ANDROID_HOME')
exit(1)

if not projlist:
print('no valid android project found in '+os.path.abspath(dir))
exit(1)

pnlist = [package_name_fromapk(i,sdkdir) for i in projlist]
portlist = [0 for i in pnlist]
stlist = [-1 for i in pnlist]

adbpath = get_adb(sdkdir)
if not adbpath:
print('adb not found in %s/platform-tools'%sdkdir)
Expand Down