本文整理汇总了Python中core.tns.tns.Tns.build_android方法的典型用法代码示例。如果您正苦于以下问题:Python Tns.build_android方法的具体用法?Python Tns.build_android怎么用?Python Tns.build_android使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.tns.tns.Tns
的用法示例。
在下文中一共展示了Tns.build_android方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_301_build_project_with_space_release
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_301_build_project_with_space_release(self):
Tns.create_app(self.app_name_space)
Tns.platform_add_android(
attributes={"--path": "\"" + self.app_name_space + "\"", "--frameworkPath": ANDROID_PACKAGE})
# Ensure ANDROID_KEYSTORE_PATH contain spaces (verification for CLI issue 2650)
Folder.create("with space")
base_path, file_name = os.path.split(ANDROID_KEYSTORE_PATH)
cert_with_space_path = os.path.join("with space", file_name)
File.copy(src=ANDROID_KEYSTORE_PATH, dest=cert_with_space_path)
# Verify project builds
Tns.build_android(attributes={"--path": "\"" + self.app_name_space + "\"",
"--keyStorePath": "\"" + cert_with_space_path + "\"",
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
"--keyStoreAlias": ANDROID_KEYSTORE_ALIAS,
"--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS,
"--release": ""
})
output = File.read(self.app_name_space + os.sep + "package.json")
assert app_identifier in output.lower()
output = File.read(
self.app_name_space + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml")
assert app_identifier in output.lower()
示例2: test_311_build_android_with_custom_compile_sdk_old
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_311_build_android_with_custom_compile_sdk_old(self):
#https://github.com/NativeScript/nativescript-cli/issues/4052
# This is required when build with different SDK
Folder.cleanup(self.app_name)
Tns.create_app(self.app_name)
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
Tns.build_android(attributes={"--compileSdk": "27", "--path": self.app_name})
示例3: test_300_build_demo
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_300_build_demo(self):
# TODO: Run npm scripts from plugin seed (build plugin, link plugin and then build the app).
Tns.plugin_create(name=self.plugin_name)
demo_path = self.plugin_name + os.sep + 'demo'
Tns.build_android(attributes={"--path": demo_path})
if CURRENT_OS == OSType.OSX:
Tns.build_ios(attributes={"--path": demo_path})
示例4: test_321_build_with_copy_to_option
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_321_build_with_copy_to_option(self):
# TODO: Remove those lines after https://github.com/NativeScript/nativescript-cli/issues/2547 is fixed.
# This is required when build with different SDK
Folder.cleanup(self.app_name)
Tns.create_app(self.app_name)
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
File.remove(self.debug_apk)
Tns.build_android(attributes={"--path": self.app_name, "--copy-to": "./"})
assert File.exists(self.debug_apk)
File.remove(self.debug_apk)
示例5: test_399_build_project_with_gz_file
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_399_build_project_with_gz_file(self):
# This is required when build with different SDK
Folder.cleanup(self.app_name)
Tns.create_app(self.app_name)
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
# Create zip
run("tar -czf " + self.app_name + "/app/app.tar.gz " + self.app_name + "/app/app.js")
assert File.exists(self.app_name + "/app/app.tar.gz")
# Build the project
Tns.build_android(attributes={"--path": self.app_name})
示例6: test_002_build_android_release
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_002_build_android_release(self):
Tns.build_android(attributes={"--path": self.app_name,
"--keyStorePath": ANDROID_KEYSTORE_PATH,
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
"--keyStoreAlias": ANDROID_KEYSTORE_ALIAS,
"--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS,
"--release": ""
}, log_trace=True)
# Configs are respected
assert 'release' in File.read(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, 'config.json'))
assert File.exists(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_RELEASE_PATH, self.release_apk))
示例7: test_451_resources_update
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_451_resources_update(self):
target_app = os.path.join(TEST_RUN_HOME, BaseClass.app_name)
source_app = os.path.join(TEST_RUN_HOME, 'data', 'apps', 'test-app-js-41')
Folder.cleanup(target_app)
Folder.copy(source_app, target_app)
output = Tns.run_tns_command("resources update", attributes={"--path": self.app_name})
assert "Successfully updated your project's application resources '/Android' directory structure" in output
assert "The previous version of your Android application resources has been renamed to '/Android-Pre-v4'" in output
assert File.exists(self.app_name + "/app/App_Resources/Android-Pre-v4/app.gradle")
assert File.exists(self.app_name + "/app/App_Resources/Android/app.gradle")
assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/AndroidManifest.xml")
assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/assets")
assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/java")
assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/res/values")
Tns.build_android(attributes={"--path": self.app_name})
示例8: test_202_build_android_with_log_trace_and_platform_not_added_or_empty
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_202_build_android_with_log_trace_and_platform_not_added_or_empty(self):
"""'tns build android' with log trace options should output more logs."""
Tns.create_app(self.app_no_platform)
output = Tns.build_android(attributes={"--path": self.app_no_platform}, log_trace=True)
# Assert log trace show gradle logs
assert "[DEBUG]" in output
assert "FAILURE" not in output
示例9: test_200_build_android_inside_project_folder
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_200_build_android_inside_project_folder(self):
Folder.navigate_to(self.app_name)
output = Tns.build_android(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name},
assert_success=False, log_trace=True)
Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)
assert successfully_prepared in output
assert build_successful in output
assert successfully_built in output
assert File.exists(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk))
示例10: test_313_build_android_with_invalid_compile_sdk
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_313_build_android_with_invalid_compile_sdk(self):
# This is required when build with different SDK
Folder.cleanup(self.app_name)
Tns.create_app(self.app_name)
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
output = Tns.build_android(attributes={"--compileSdk": "99", "--path": self.app_name},
assert_success=False)
assert "You have specified '99' for compile sdk, but it is not installed on your system." in output
示例11: test_300_build_project_with_dash_and_ios_inspector_added
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_300_build_project_with_dash_and_ios_inspector_added(self):
"""
Verify we can build projects with dashes.
Verify we can build android when inspector is added (test for CLI issue 2467)
"""
Tns.create_app(self.app_name_dash)
Tns.platform_add_android(attributes={"--path": self.app_name_dash, "--frameworkPath": ANDROID_PACKAGE})
if USE_YARN == "True":
Npm.install(package="tns-ios-inspector", option='--dev', folder=self.app_name_dash)
else:
Npm.install(package="tns-ios-inspector", option='--save-dev', folder=self.app_name_dash)
Tns.build_android(attributes={"--path": self.app_name_dash})
# Verify project id
output = File.read(self.app_name_dash + "/package.json")
assert app_identifier in output.lower()
# Verify AndroidManifest.xml
output = File.read(self.app_name_dash + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml")
assert app_identifier in output.lower()
示例12: test_205_build_android_app_bundle_env_snapshot
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_205_build_android_app_bundle_env_snapshot(self):
"""Build app with android app bundle option with --bundle and optimisations for snapshot.
Verify the output(app.aab) and use bundletool to deploy on device."""
# This test will not run on windows because env.snapshot option is not available on that OS
path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab")
#Configure app with snapshot optimisations
source = os.path.join('data', 'abdoid-app-bundle', 'app.gradle')
target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle' )
File.copy(src=source, dest=target)
source = os.path.join('data', 'abdoid-app-bundle', 'webpack.config.js')
target = os.path.join(self.app_name, 'webpack.config.js' )
File.copy(src=source, dest=target)
#env.snapshot is applicable only in release build
output = Tns.build_android(attributes={"--path": self.app_name,
"--keyStorePath": ANDROID_KEYSTORE_PATH,
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
"--keyStoreAlias": ANDROID_KEYSTORE_ALIAS,
"--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS,
"--release": "",
"--aab": "",
"--env.uglify": "",
"--env.snapshot": "",
"--bundle": ""
}, assert_success=False)
assert "The build result is located at:" in output
assert path_to_aab in output
assert File.exists(path_to_aab)
#Verify app can be deployed on emulator via bundletool
# Use bundletool to create the .apks file
self.bundletool_build(self.bundletool_path, path_to_aab, self.path_to_apks)
assert File.exists(self.path_to_apks)
# Verify that the correct .so file is included in the package
File.unzip(self.path_to_apks, os.path.join(self.app_name, 'apks'))
File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), os.path.join(self.app_name,'base_apk'))
assert File.exists(os.path.join(self.app_name, 'base_apk', 'lib', 'x86', 'libNativeScript.so'))
# Deploy on device
self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=EMULATOR_ID)
# Start the app on device
Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp")
# Verify app looks correct inside emulator
app_started = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP')
assert app_started, 'App is not started on device'
示例13: test_200_build_android_app_bundle
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_200_build_android_app_bundle(self):
"""Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device"""
path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab")
output = Tns.build_android(attributes={"--path": self.app_name, "--aab":""}, assert_success=False)
assert "The build result is located at:" in output
assert path_to_aab in output
assert File.exists(path_to_aab)
#Verify app can be deployed on emulator via bundletool
# Use bundletool to create the .apks file
self.bundletool_build(self.bundletool_path, path_to_aab, self.path_to_apks)
assert File.exists(self.path_to_apks)
# Deploy on device
self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=EMULATOR_ID)
# Start the app on device
Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp")
# Verify app looks correct inside emulator
app_started = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP')
assert app_started, 'App is not started on device'
示例14: test_001_build_android
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_001_build_android(self):
Tns.build_android(attributes={"--path": self.app_name})
assert File.pattern_exists(self.platforms_android, "*.aar")
assert not File.pattern_exists(self.platforms_android, "*.plist")
assert not File.pattern_exists(self.platforms_android, "*.android.js")
assert not File.pattern_exists(self.platforms_android, "*.ios.js")
# Configs are respected
assert 'debug' in File.read(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, 'config.json'))
# And new platform specific file and verify next build is ok (test for issue #2697)
src = os.path.join(self.app_name, 'app', 'app.js')
dest_1 = os.path.join(self.app_name, 'app', 'new.android.js')
dest_2 = os.path.join(self.app_name, 'app', 'new.ios.js')
File.copy(src=src, dest=dest_1)
File.copy(src=src, dest=dest_2)
# Verify incremental native build
before_build = datetime.datetime.now()
output = Tns.build_android(attributes={"--path": self.app_name})
after_build = datetime.datetime.now()
assert "Gradle build..." in output, "Gradle build not called."
assert output.count("Gradle build...") is 1, "Only one gradle build is triggered."
assert (after_build - before_build).total_seconds() < 20, "Incremental build takes more then 20 sec."
# Verify platform specific files
assert File.pattern_exists(self.platforms_android, "*.aar")
assert not File.pattern_exists(self.platforms_android, "*.plist")
assert not File.pattern_exists(self.platforms_android, "*.android.js")
assert not File.pattern_exists(self.platforms_android, "*.ios.js")
# Verify apk does not contain aar files
archive = ZipFile(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk))
archive.extractall(self.app_name + "/temp")
archive.close()
# Ceanup META-INF folder. It contains com.android.support.... files which are expected to be there due to
# https://github.com/NativeScript/nativescript-cli/pull/3923
Folder.cleanup(os.path.join(self.app_name, "temp", "META-INF"))
assert not File.pattern_exists(self.app_name + "/temp", "*.aar")
assert not File.pattern_exists(self.app_name + "/temp", "*.plist")
assert not File.pattern_exists(self.app_name + "/temp", "*.android.*")
assert not File.pattern_exists(self.app_name + "/temp", "*.ios.*")
Folder.cleanup(self.app_name + "/temp")
# Verify incremental native build
before_build = datetime.datetime.now()
output = Tns.build_android(attributes={"--path": self.app_name})
after_build = datetime.datetime.now()
assert "Gradle build..." in output, "Gradle build not called."
assert output.count("Gradle build...") is 1, "Only one gradle build is triggered."
assert (after_build - before_build).total_seconds() < 20, "Incremental build takes more then 20 sec."
# Verify clean build force native project rebuild
before_build = datetime.datetime.now()
output = Tns.build_android(attributes={"--path": self.app_name, "--clean": ""})
after_build = datetime.datetime.now()
build_time = (after_build - before_build).total_seconds()
assert "Gradle clean..." in output, "Gradle clean is not called."
assert "Gradle build..." in output, "Gradle build is not called."
assert output.count("Gradle build...") is 1, "More than 1 gradle build is triggered."
assert build_time > 10, "Clean build takes less then 15 sec."
assert build_time < 90, "Clean build takes more than 90 sec."
示例15: test_406_build_release_without_key_options
# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import build_android [as 别名]
def test_406_build_release_without_key_options(self):
output = Tns.build_android(attributes={"--release": "", "--path": self.app_name}, assert_success=False)
assert "When producing a release build, you need to specify all --key-store-* options." in output
assert "# tns build android" in output
assert not File.exists(
os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_RELEASE_PATH, self.release_apk))