我正在尝试使用twitter4j库为我的java项目发送推文.在我第一次运行时,我收到了关于证书sun.security.validator.ValidatorException和错误的错误sun.security.provider.certpath.SunCertPathBuilderException.然后我添加了twitter证书:
C:\Program Files\Java\jdk1.7.0_45\jre\lib\security>keytool -importcert -trustcacerts -file PathToCert -alias ca_alias -keystore "C:\Program Files\Java\jdk1.7.0_45\jre\lib\security\cacerts"
Run Code Online (Sandbox Code Playgroud)
但没有成功.这是获得twitters的过程:
public static void main(String[] args) throws TwitterException {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("myConsumerKey")
.setOAuthConsumerSecret("myConsumerSecret")
.setOAuthAccessToken("myAccessToken")
.setOAuthAccessTokenSecret("myAccessTokenSecret");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
Query query = new Query("iphone");
QueryResult result;
result = twitter.search(query);
System.out.println("Total amount of tweets: " + result.getTweets().size());
List<Status> tweets = result.getTweets();
for (Status tweet : tweets) {
System.out.println("@" + tweet.getUser().getScreenName() + " …Run Code Online (Sandbox Code Playgroud) 我已经看过这个问题.但这适用于Mac OS.我正在使用Windows.每次我创建一个新项目或尝试build/rebuild该项目它冻结!! 我安装了最新版本(2016年10月9日).但情况正在恶化.我想完全删除它并安装它,就像我第一次安装它一样.任何帮助都应该得到赞赏.
忽略这个警告是否安全?它在我在Android Studio中创建新项目时出现:
Server's certificate is not trusted
Certificate details
Issued To
CN (Common Name) *.google.com
O (Organization) Google Inc
L (Locality) Mountain View
C (Country) US
ST (State or Province) California
Issued By
CN (Common Name) Google Internet Authority G2
O (Organization) Google Inc
C (Country) US
Validity Period
Valid from: 9/24/14
Valid until: 12/23/14
...
Run Code Online (Sandbox Code Playgroud)
日期看起来没问题,我检查了我的电脑的日期设置,以确定.为什么它会"不信任"?
我在Android Studio中遇到了gradle构建错误,如下所示:
Error:A problem occurred configuring project ':MyApp'.
Could not resolve all dependencies for configuration ':MyApp:classpath'.
Could not resolve io.fabric.tools:gradle:1.+.
Required by:
sw-android:MyApp:unspecified
Failed to list versions for io.fabric.tools:gradle.
Unable to load Maven meta-data from
https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml.
Could not GET 'https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml'.
peer not authenticated
Failed to list versions for io.fabric.tools:gradle.
Unable to load Maven meta-data from
http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml.
Could not GET http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml'.
peer not authenticated
Run Code Online (Sandbox Code Playgroud)
我发现"https"标签无法下载Maven URL,所以我在我的build.gradle文件中将https更改为http.此外,我检查了所有gradle设置并手动修改路径C:\ Users\Ashfaque1.AndroidStudio\config\options \中的other.xml文件,但仍然采用https://repo1.maven.org/maven2/io /fabric/tools/gradle/maven-metadata.xml.此外,一旦我点击浏览器的这个链接,我得到404异常,但错误的第二个URL http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml,我能够成功点击并在我的系统中正确下载元数据文件.无法理解问题所在,我需要更改设置以便下载元数据文件.请建议我是否需要更改任何设置或更改此URL的位置 https://repo1.maven.org/maven2//io/fabric/tools/gradle/maven-metadata.xml
我的build.gradle文件如下:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric' …Run Code Online (Sandbox Code Playgroud) 我为我的服务器生成了自签名证书.然后使用设置 - >安全性 - >安装将其添加到Android.
当我尝试使用应用程序连接到我的服务器时,我收到错误:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)
据我所知,在我将证书添加到可信任之后它应该可以正常使用我的服务器,或者我可能会遗漏一些东西?这个想法是通过Android系统添加证书,不要更改应用程序代码.
顺便说一句,我OkHttpClient用于网络连接.也许我应该为https连接启用一些东西?
当我尝试创建空活动项目时,我在Android Studio 2.3.2中遇到以下错误.当我尝试导入项目时,我也得到了这个.
Error:Cause: unable to find valid certification path to requested target
Run Code Online (Sandbox Code Playgroud)
在这里,我的gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
和
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0" …Run Code Online (Sandbox Code Playgroud) ssl android android-studio android-gradle-plugin gradle-plugin