Gradle: package com.parse does not exist - java

I am trying to add the Parse SDK into my app. Here is the steps I took:
Dragged all Parse files into my libs folder
Add the following lines to my code:
import com.parse.Parse;
import com.parse.ParseAnalytics;
Went to my build.gradle and added:
compile files('libs/Parse-1.4.1-javadoc/Parse-1.4.1.jar')
However I am still getting these errors:
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist

Change compile files('libs/Parse-1.4.1-javadoc/Parse-1.4.1.jar') to compile files('libs/Parse-1.4.1.jar')

If you see your jar file in explorer on the left side, click right button of your mouse and then 'Add as Library'. It just helped me.

I added the Parse-SDK into my app as follows:
Dependency: Add this in your root build.gradle file (not your module build.gradle file):
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Then, add the library to your project build.gradle
dependencies {
implementation "com.github.parse-community.Parse-SDK-Android:parse:*latest.version.here*"
// for FCM Push support (optional)
implementation "com.github.parse-community.Parse-SDK-Android:fcm:*latest.version.here*"
// for Kotlin extensions support (optional)
implementation "com.github.parse-community.Parse-SDK-Android:ktx:*latest.version.here*"
}
replacing latest.version.here with the latest released version (in my case 1.18.5).
More details here: https://github.com/parse-community/Parse-SDK-Android/.
I am not to sure if that achieves the same purpose as what you wanted.

Related

Can't import any library to Android Studio and Gradle Failed to Resolve

I have tried these two libraries in order to make Image Zoomable, but I'm facing the same problem.
This is the error message
Failed to resolve: com.github.MikeOrtiz:TouchImageView:1.4.1
Show in Project Structure dialog
Affected Modules: app
At first, I thought it's maybe because of Jetpack Compose with Java, Because I tried to use TouchImageView Library as I've mentioned here,
implementation 'com.github.MikeOrtiz:TouchImageView:1.4.1'
for this Library, it was needed to import
maven { url 'https://jitpack.io' }
I did import it to build.gradle project, also there was no allproject in that file, then I tried to import it into settings.gradle as well. in short, I just faced the same error message image is shown below
Go to settings.gradle
Add this line at bottom: include ':app',':touchview'
Add maven { url 'https://jitpack.io' } to
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories

Unable to add library to Android Studio project

I'm trying to add this library to Android Studio locally using this tutorial on YouTube.
However, I get errors that I can't post here because they're too many (99+).
Can someone tell me step by step (in detail) how to succesfully add this library to my project and be able to edit it afterwards?
This is the main error I get when I try to import this library: `Unable to determine constructor argument #1: missing parameter of type Factory, or no service of type Factory.
My build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is your step-by-step guide:
Create an empty project or open your existing project where you want to add this library.
Clone the library project from the git or download the zip and extract it in some other directory.
Now, in Android Studio, go to File -> New -> Import Module.... Select the cloned/extracted library directory. Make sure the :placepicker module is selected for import. Then click Finish.
Now copy two files bintray.gradle and install.gradle from cloned/extracted project root directory to your own project root directory. Add this point your project structure should look like this:
Now open your project level build.gradle. Add ext.kotlin_version = '1.3.72' inside buildscript { and also add following dependencies:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
Overall, this will look like:
Finally, go to File -> Sync Project with Gradle Files. It will take some time to download the missing dependencies and you have now successfully integrated the library within your project which is fully editable.
Now to make this library work in your own app module, in the build.gradle file of your app module, add this inside dependencies section:
api project(':placepicker')
Or edit your gradle.build like in the picture:
Step by step description:
Then ceck out the git project to your machine.
Modify and build it with a new Version.
Add the dipendency as Jar from Your local filesystem in Android Studio.
Try this:
File > Project Structure > Dependencies Tab > Add module dependency (scope = compile)
Where the module dependency is the project library Android folder.
In build.gradle(Module.app) file add this.
implementation 'com.google.android.gms:play-services-places:17.0.0'
let me knew if it's work.

Unable to build gradle project in eclipse?

After cleaning when i try to build gradle i get an error in the console saying:
package org.json does not exist import org.json.JSONObject;
cannot find symbol
symbol : class JSONObject
there are red marks in the java file at all places where jsonobject and json array exists.
I have put the folder web inf/lib that contains all the jar files inside the src/main/webapp directory that i have created.
currently the contents of my build.gradle file are:
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'i2cdev001' at '14/11/18 3:11 PM' with Gradle 2.14.1
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/2.14.1/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'war'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.21'
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'
}
Note: Also in the project properties i am unable to see any jar files under the Web App Libraries in the java build path tab. I can see only access rules:no rules defined and native library locations:(none)
As your project is gradle project, Adding jar manually wont work.. You have to mention path where you have kept all your jar files in your build.gradle file.
Mention your jar file path in repository under flatDir {}:
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
Then you have to add which jar from that folder you have mentioned above (ie libs)
dependencies {
compile 'gson-0.1.0'
}

Error importing json simple library to Android Studio

I am getting this error when using an import method I found to Android Studio.
https://github.com/MagicMicky/FreemiumLibrary/wiki/Import-the-library-in-Android-Studio
The import method I am using is in the above link.
This is the error message (Click Here)
This is how it is in the settings.gradle
include ':app',':lib:json-simple-master'
and this is how I edited the build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
compile project(':lib:json-simple-master')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
This is how I am trying to import the file
import org.json.simple.*;
You shouldn't need to follow those instructions
But you edited the wrong build.gradle file.
Update the one like this
android {
...
}
dependencies {
...
compile group: 'com.magicmicky.freemiumlibrary', name: 'library', version: '1.1'
}
If you want a JSON library, android already has org.json... If you want Java object deserialization, use Jackson or Gson.
json-simple doesn't seem necessary in an app

Cannot Resolve ContextCompat in Android

I have an AlertDialogue object called dialog. I am attempting to add an icon to it. I see that this syntax is now deprecated:
dialog.setIcon(getResources().getDrawable(R.drawable.myImage);
I'm reading everywhere that this should work:
dialog.setIcon(ContextCompat.getDrawable(context, R.drawable.myImage));
However, the ContextCompat syntax is not being recognized by Android Studio. Is there something that I should be importing? Thank you.
***Update: Thank's to #Sharj for the correct answer below. I made a quick video too if you guys need a visual: https://www.youtube.com/watch?v=eFiaO0srQro&feature=youtu.be
ContextCompat is part of support library v4. Have you added support library 4 to your project?
android.support.v4.content.ContextCompat
You can include support library to your build.gradle file under app folder if you haven't already
dependencies {
// other stuff here
compile 'com.android.support:support-v4:23.0.0'
// update the 23.0.0 to latest version available
}
androidx.core.content.ContextCompat
from AndroidX dependency
implementation 'androidx.appcompat:appcompat:1.1.0'
I had the same issue and this and a few more posts helped me.
With Android studio you have multiple Gradle files.
I got my code to work by adding the dependencies section into Gradle (Module : Library) or the file that has "android {" ...
dependencies {
// other stuff here
compile 'com.android.support:support-v4:23.+'
// update the 23.0.0 to latest version available
}
If you are using Android gradle plugin 3.0.1, add google() to your allProjects repositories in the build.gradle file (project level) then sync
like this:
allprojects {
repositories {
google()
....
//other repos
}
}
Adding this to build.gradle(Module:App) under dependencies resolved the problem
compile 'com.android.support:support-v4:23.0.0'

Categories

Resources