appcanopensource / appcan-android Goto Github PK
View Code? Open in Web Editor NEWappcan-android
License: GNU Lesser General Public License v3.0
appcan-android
License: GNU Lesser General Public License v3.0
我在页面中设置 img
src
属性的时候,如果图片设置成我们服务器的 https
链接,那么图片就不会显示。代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Title Here</title>
<script type="text/javascript"></script>
</head>
<body>
<div class="uwh-bg umar-r-ect uwh-bg-img" id="imgtest">
<img class="upimg" id="imgtesta" src="https://172.28.1.209/image......" width="100px" height="100px"/>
</div>
</body>
</html>
不能正确显示来自服务器的图片:
我排查后发现这是 https 证书配置问题,错误日志:
I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
页面中的 https
请求都是没问题的:
appcan.ajax({
type:"POST",
url:baseUrl+url,
data:data
offline:false,
expire:1000,
timeout : 30000,
dataType: 'json',
beforeSend:function(xhr){
},
success:function(ret,status,xhr){
},
error:function(xhr,type){
}
});
我试着在修改引擎代码,不要去做证书校验,在 org.zywx.wbpalmstar.platform.certificates.Http
中忽略证书校验:
public class Http {
public static HashMap<String, KeyStore> KEY_STORE = new HashMap<String, KeyStore>();
public static String algorithm = "X509";
public static String keyType = "pkcs12";
/**
* 是否检查https证书为可信机构颁发
*/
private static boolean isCheckTrustCert = false;
private static InputStream getInputStream(String cPath, Context ctx)
throws IOException, FileNotFoundException {
InputStream inStream;
String assertFile = "file:///android_asset/";
String sdcardFile = "/sdcard/";
String wgtFile = "widget/";
String file = "file://";
if (cPath.contains(assertFile)) {
cPath = cPath.substring(assertFile.length());
AssetManager asset = ctx.getAssets();
inStream = asset.open(cPath);
} else if (cPath.contains(sdcardFile)) {
if (cPath.contains(file)) {
cPath = cPath.substring("file://".length());
}
inStream = new FileInputStream(cPath);
} else if (cPath.startsWith(wgtFile)) {
AssetManager asset = ctx.getAssets();
inStream = asset.open(cPath);
} else {
inStream = new FileInputStream(cPath);
}
return inStream;
}
public static javax.net.ssl.SSLSocketFactory getSSLSocketFactoryWithCert(String cPassWord, String cPath, Context ctx) {
Log.e("httptest", "httptest == getSSLSocketFactoryWithCert(String cPassWord, String cPath, Context ctx)");
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
TrustManager[] tm = {new HX509TrustManager()};
try {
sslContext.init(null, tm, new java.security.SecureRandom());
} catch (KeyManagementException e) {
e.printStackTrace();
}
return sslContext.getSocketFactory();
}
public static javax.net.ssl.SSLSocketFactory getSSLSocketFactory() {
Log.e("httptest", "httptest == getSSLSocketFactory()");
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
TrustManager[] tm = {new HX509TrustManager()};
try {
sslContext.init(null, tm, new java.security.SecureRandom());
} catch (KeyManagementException e) {
e.printStackTrace();
}
return sslContext.getSocketFactory();
}
public static HttpsURLConnection getHttpsURLConnection(URL url) throws Exception {
Log.e("httptest", "httptest == getHttpsURLConnection(URL url)");
HttpsURLConnection mConnection = null;
mConnection = (HttpsURLConnection) url.openConnection();
javax.net.ssl.SSLSocketFactory ssFact = null;
ssFact = Http.getSSLSocketFactory();
((HttpsURLConnection) mConnection).setSSLSocketFactory(ssFact);
if (!isCheckTrustCert()) {
((HttpsURLConnection) mConnection)
.setHostnameVerifier(new HX509HostnameVerifier());
} else {
((HttpsURLConnection) mConnection)
.setHostnameVerifier(new HX509HostnameVerifier());
}
return mConnection;
}
public static HttpsURLConnection getHttpsURLConnection(String urlString) throws Exception {
URL url=new URL(urlString);
HttpsURLConnection mConnection = getHttpsURLConnection(url);
return mConnection;
}
public static HttpsURLConnection getHttpsURLConnectionWithCert(URL url,
String cPassWord, String cPath, Context ctx) throws Exception {
HttpsURLConnection mConnection = null;
mConnection = (HttpsURLConnection) url.openConnection();
javax.net.ssl.SSLSocketFactory ssFact = null;
ssFact = Http.getSSLSocketFactoryWithCert(cPassWord, cPath, ctx);
((HttpsURLConnection) mConnection).setSSLSocketFactory(ssFact);
if (!isCheckTrustCert()) {
((HttpsURLConnection) mConnection)
.setHostnameVerifier(new HX509HostnameVerifier());
} else {
((HttpsURLConnection) mConnection)
.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
}
return mConnection;
}
public static boolean isCheckTrustCert() {
return isCheckTrustCert;
}
public static void setCheckTrustCert(boolean isCheckTrustCert) {
Http.isCheckTrustCert = isCheckTrustCert;
}
}
但是这并没有解决我们的问题,我在网上搜索之后发现 appcan 类似的问题:https自定义证书如何能通过安全认证,但是也是一直没有解决。
网上搜索发现在 onReceivedSslError
方法中接受证书就可以解决问题。
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){
handler.proceed();
}
});
我该如何在 appcan
项目中配置 https
证书呢?
或者我该如何让我的 appcan
项目里全局请求网络的时候忽略校验证书呢?
PS:项目已整体迁移到 Android Studio
中了。
你好你们的引擎能否增加一下对这个路径的优化。拍照获取的图片,竟然无法显示。
如下代码,这个最基本的功能,竟然死活实现不了。。
function APPCAN_openCamera(){
var self = this
var comtextareass = 0 // 图片是否压缩,0表示压缩,非0或者不传表示不压缩
var quality = 50 // 图片压缩质量,comtextareass为0时有效,取值范围[0,100]
uexCamera.openInternal(comtextareass, quality, function(picPath) {
alert(picPath)
// picPath = "/storage/emulated/0/widgetone/apps/11461287/photo/scan20171120135143.jpg"
document.querySelector('.thumbImg').src =picPath
})
}
修改Engine/gradle/wrapper/gradle-wrapper.properties,其中版本改为4.1;
修改Engine/build.gradle文件中。其中,repositories增加一个github的maven库,dependencies中将原来的依赖本地的gradle插件改为依赖线上的,版本目前是2.2.3,可以在此仓库关注更新 https://github.com/android-plugin/mvn-repo
修改部分参考下面:
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://raw.githubusercontent.com/android-plugin/mvn-repo/master/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// classpath fileTree(dir: '../gradle-plugin', include: '*.jar')
classpath 'org.appcan.gradle.plugins:appcan-gradle-plugin:2.2.3'
}
}
dependencies中com.android.tools.build:gradle设置为3.0.1之后,需要在所有的repositories中增加google(),否则会找不到Android新版的官方gradle相关插件库而报错;
若buildToolsVersion改为26或更高后,还会要求修改flavor的定义,如下修改即可:
//声明flavorDimension
flavorDimensions "kernel"
productFlavors {
crosswalk {
dimension "kernel"
}
system {
dimension "kernel"
}
x5 {
dimension "kernel"
}
}
请问能否实现安卓原生应用的短信发送,电话录音,录制视频等功能?哪里找相关参考资料呢?
在android10以下h5页面展示正常,在android 10上页面展示异常:
1.页面中出现小窗口,小窗口可以左右上下滑动;
2.原来是一个页面,现在是一个底层页面,然后内容部分成了小窗口展示;
Android Studio 打包 AppCan 项目时 assets 目录下文件无法进行加密:
因为 AppCan 线上打包速度慢的原因,我们把项目转移到 Android Studio 上了。现在打包 apk 的时候发现 assets 目录下文件都没有加密。
PS:项目中的 config.xml
文件 <obfuscation>false</obfuscation>
改为了 false, 不然 app 运行时会报找不到页面的错误。
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<widget...>
<name>appname</name>
<description/>
<author email=""> </author>
<icon src="icon.png"/>
<license href=""/>
<content encoding="utf-8" src="index.html"/>
<updateurl/>
<logserverip/>
<showmyspace>false</showmyspace>
<obfuscation>false</obfuscation>
<bgcolor>#fefefe</bgcolor>
<orientation>15</orientation>
<debug/>
<partobfuscation/>
<webapp/>
</widget>
Android Studio 打包 AppCan 项目后反编译 apk, assets 目录下文件打开都是乱码。
Android Studio 打包 AppCan 项目后反编译 apk, assets 目录下文件打开可以看见源码,没有进行任何加密。
我们该如何在 Android Studio
版 AppCan
项目中配置,已达到加密 AppCan
代码( assets
目录下文件)的目的?
修改Engine/gradle/wrapper/gradle-wrapper.properties,其中版本改为5.4.1;
修改Engine/build.gradle文件中。其中,repositories增加一个github的maven库,dependencies中将原来的依赖本地的gradle插件改为依赖线上的,版本目前是2.3.1,可以在此仓库关注更新 https://github.com/android-plugin/mvn-repo。修改部分参考下面:
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://raw.githubusercontent.com/android-plugin/mvn-repo/master/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// classpath fileTree(dir: '../gradle-plugin', include: '*.jar')
classpath 'org.appcan.gradle.plugins:appcan-gradle-plugin:2.3.1'
}
}
问题是这样的,我们的项目要适配三个屏幕,在 800*1080
和 720*1280
的机器上都显示的很好,但是在另一个 1280*1920
的机器上显示的效果很差,所以我们需要做屏幕适配。我想用 像素密度 适配的方式来适配我们的 AppCan 项目,但是没有任何效果,想请问一下这个方案对于 AppCan 项目来说是否可行?
AppCan 这个框架是如何做屏幕适配的呢?
Originally posted by @aixiaozi in #153 (comment)
编译要用jdk1.8吧,1.7编译不过
你好,按照步骤下载源码后编译不通过,错误:Error:No such property: metadataCharset for class: org.gradle.api.tasks.bundling.Zip_Decorated,请问这种情况如何解决?
↑1 AppCanPlugin/Engine_AppCan → ./gradlew buildEngine
Configure project :app
Observed package id 'build-tools;22.0.0' in inconsistent location '/Users/xxx/Work/IDE/android-sdk-macosx/build-tools/android-5.1' (Expected '/Users/xxx/Work/IDE/android-sdk-macosx/build-tools/22.0.0')
FAILURE: Build failed with an exception.
What went wrong:
Task 'buildEngine' not found in root project 'Engine_AppCan'.
Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
↑1 AppCanPlugin/Engine_AppCan →
使用文档里面编译引擎命令如上错误。
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java_lang_String$substring$2.call(Unknown Source)
at com.appcan.AppCanPlugin.getEngineZipVersion(AppCanPlugin.groovy:151)
执行gradle task buildSystemEngine 报错
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.