react-native-twitter-signin / twitter-signin

react-native twitter signin using TwitterKit5
MIT License
25 stars 16 forks source link

Could not find com.twitter.sdk.android:twitter-core:3.3.0. #21

Open deleonjuan opened 10 months ago

deleonjuan commented 10 months ago

Hey - I'm tring to use this library but I'm getting the next error. I just npm installed the package and then when npm start and npm run android I get the error.

I followed the instructions in the README.md and from here https://rnfirebase.io/auth/social-auth, but no success.

image

* What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.twitter.sdk.android:twitter-core:3.3.0.
     Searched in the following locations:
       - https://oss.sonatype.org/content/repositories/snapshots/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom
       - https://repo.maven.apache.org/maven2/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom
       - file:/C:/Users/Juandl/dev/slappr/node_modules/jsc-android/dist/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom
       - https://dl.google.com/dl/android/maven2/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom
       - https://www.jitpack.io/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom
     Required by:
         project :app > project :react-native-twitter-signin_twitter-signin

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 11s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':app:processDebugResources'. > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. > Could not find com.twitter.sdk.android:twitter-core:3.3.0. Searched in the following locations: - https://oss.sonatype.org/content/repositories/snapshots/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom - https://repo.maven.apache.org/maven2/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom - file:/C:/Users/Juandl/dev/slappr/node_modules/jsc-android/dist/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom - https://dl.google.com/dl/android/maven2/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom - https://www.jitpack.io/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.pom Required by: project :app > project :react-native-twitter-signin_twitter-signin * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 11s.
crestcoder-cc commented 10 months ago

Same issue Could not find com.twitter.sdk.android:twitter:3.3.0. Did you get any solution for the same?

shuklaom84 commented 10 months ago

FAILURE: Build failed with an exception.

shuklaom84 commented 10 months ago

i found solution

actually the jcenter repository url has been changed so this

buildscript { ext { buildToolsVersion = "34.0.0" minSdkVersion = 21 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "25.1.8937393" kotlinVersion = "1.8.0" }

repositories {
    google()
    mavenCentral()
    jcenter()
}

allprojects {
repositories {
    mavenCentral()
    mavenLocal()
     **maven { url 'https://jcenter.bintray.com/' }**    (this jcenter url need to write) and u will get working code 

} }

dependencies {
    classpath("com.android.tools.build:gradle")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}

}

apply plugin: "com.facebook.react.rootproject"

devGbarbosa commented 4 months ago

Any updates on this issue? It wasn't working for me yet.

shuklaom84 commented 4 months ago

in android 14 some settings seed to do ..i will share with you just given me some time ..

shuklaom84 commented 4 months ago

can you share your error .. what error are you facing ?

devGbarbosa commented 4 months ago

Sure, my problem is exactly what've been described in the issue title, it's not able to find com.twitter.sdk.android:twitter-core:3.3.0.

I've tried to use maven {url: ''} and rollback jCenter(), but unfortunately still not working

shuklaom84 commented 4 months ago

"@react-native-twitter-signin/twitter-signin": "^1.2.0", this is my plugin From Package.json

create a network security file in res folder <?xml version="1.0" encoding="utf-8"?>

api.twitter.com
<application 
    android:name=".MainApplication" 
    android:label="@string/app_name" 
    android:icon="@mipmap/ic_launcher" 
    android:networkSecurityConfig="@xml/network_security_config"
    android:allowBackup="false" 
    android:theme="@style/AppTheme">

android->app->build.gradel

apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" apply plugin: 'com.google.gms.google-services' apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" /**

/**

/**

android { ndkVersion rootProject.ext.ndkVersion buildToolsVersion rootProject.ext.buildToolsVersion compileSdk rootProject.ext.compileSdkVersion

namespace <yourapp namespace>
defaultConfig {
    applicationId <your app application id>
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

}

dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") implementation ("com.facebook.fresco:animated-gif:3.1.0") implementation("com.facebook.react:flipper-integration") implementation project(':react-native-vector-icons') implementation platform('com.google.firebase:firebase-bom:32.7.2') implementation 'com.stripe:stripe-android:20.42.0' //implementation project(':react-native-splash-screen') implementation project(':react-native-push-notification') implementation project(':react-native-splash-screen') //implementation project(':react-native-twitter-signin') //implementation project(':react-native-login-twitter') //implementation 'com.twitter.sdk.android:twitter-core:3.2.0' if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } }

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android-> build.gradel

buildscript { ext { buildToolsVersion = "34.0.0" minSdkVersion = 21 compileSdkVersion = 34 targetSdkVersion = 28 ndkVersion = "25.1.8937393" kotlinVersion = "1.8.0"

}

repositories {
    google()
    mavenCentral()
    jcenter()
}

allprojects {
repositories {
    mavenCentral()
    mavenLocal()
     maven { url 'https://jcenter.bintray.com/' }

} }

dependencies {
    classpath("com.android.tools.build:gradle")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    // classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
     classpath 'com.google.gms:google-services:4.3.15'

}

}

apply plugin: "com.facebook.react.rootproject" apply plugin: 'com.google.gms.google-services'

please check with this code i hope this will helpful for you . twitter is working perfectly working in my project please use the twitter plugin which i mention on the top and config accordingly .definitely this will work

shuklaom84 commented 4 months ago

<?xml version="1.0" encoding="utf-8"?>

api.twitter.com localhost 10.0.2.2
shuklaom84 commented 4 months ago

image

devGbarbosa commented 4 months ago

Awesome, I'll try later and keep you posted. Thank you so much!

umerdogar commented 4 months ago

Is someone able to do twitter auth in React Native version greater that 0.70

shuklaom84 commented 4 months ago

Yes

On Thu, 4 Jul, 2024, 2:44 pm UMER DOGAR, @.***> wrote:

Is someone able to do twitter auth in React Native version greater that 0.70

— Reply to this email directly, view it on GitHub https://github.com/react-native-twitter-signin/twitter-signin/issues/21#issuecomment-2208495264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGATXHX7GL6U3PUDABNOQKLZKUG7VAVCNFSM6AAAAABJUGBBBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBYGQ4TKMRWGQ . You are receiving this because you commented.Message ID: @.*** com>

erie-e9 commented 4 months ago

Did you fix it @devGbarbosa? seems happening to me same as you after @shuklaom84 recommendations. I'm using react-native@0.74.0 and @react-native-twitter-signin/twitter-signin@1.2.0

shuklaom84 commented 4 months ago

In my app i did and it's working

On Thu, 11 Jul, 2024, 12:22 pm Eric Torres, @.***> wrote:

Did you fix it @devGbarbosa https://github.com/devGbarbosa? seems happening to me same as you after @shuklaom84 https://github.com/shuklaom84 recommendations. I'm using @. and @@.

— Reply to this email directly, view it on GitHub https://github.com/react-native-twitter-signin/twitter-signin/issues/21#issuecomment-2222171281, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGATXHXADZEUAKRG5R6ZFE3ZLYTTXAVCNFSM6AAAAABJUGBBBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRSGE3TCMRYGE . You are receiving this because you were mentioned.Message ID: @.*** com>

erie-e9 commented 4 months ago

I wonder if could u testing again in a new project with RN 0.74.3 and share ur thoughts about it @shuklaom84

bdtren commented 2 months ago

I tried adding source code of the twitter-core in my fork https://github.com/bdtren/twitter-signin, fixed the issue. But it seem useless now. In latest X app, old intent call not working anymore, even twitter://, twitterauth:// and x:// not working

shuklaom84 commented 2 months ago

hi guys , we need to change the login system .. remove everything and use below mention code in seprate tsx file

import Axios from 'axios'; import OAuth from 'oauth-1.0a'; import {useEffect} from 'react'; import {Alert, Linking} from 'react-native'; import Config from 'react-native-config'; import crypto from 'react-native-quick-crypto';

const CONSUMER_KEY = Config.TWITTER_CONSUMER_KEY; const CONSUMER_SECRET = Config.TWITTER_CONSUMER_SECRET; const TWITTER_API = 'https://api.twitter.com'; const OAUTH_CALLBACK_URL = 'oauth-app://oauth'; // your app scheme

export const useSignInWithTwitter = () => { // request token const signInWithTwitter = async () => { const oauth = new OAuth({ consumer: { key: CONSUMER_KEY, secret: CONSUMER_SECRET, }, signature_method: 'HMAC-SHA1', hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64'), });

const request_data = {
  url: `${TWITTER_API}/oauth/request_token`,
  method: 'POST',
  data: { oauth_callback: OAUTH_CALLBACK_URL },
};

const headers = {
  ...oauth.toHeader(
    oauth.authorize({
      url: request_data.url,
      method: request_data.method,
      data: { oauth_callback: OAUTH_CALLBACK_URL },
    })
  ),
  'Content-Type': 'application/x-www-form-urlencoded',
  'Accept': 'application/json',
};

try {
  // Remove the empty {} body from the post request
  const res = await Axios.post(request_data.url, null, { headers });
  const responseData = res.data;
  const requestToken = responseData.match(/oauth_token=([^&]+)/)[1];

  // Redirect to Twitter login
  const twitterLoginURL = `${TWITTER_API}/oauth/authenticate?oauth_token=${requestToken}`;
  Linking.openURL(twitterLoginURL);
} catch (error:any) {
  console.log('Error in request token:', error.response?.data || error.message);
}

};

useEffect(() => { const subscribe = Linking.addEventListener( 'url', async (event: { url: string }) => { const url = event.url; const params = url.split('?')[1]; const tokenParts = params.split('&'); const requestToken = tokenParts[0].split('=')[1]; const oauthVerifier = tokenParts[1].split('=')[1];

    const oauth = new OAuth({
      consumer: {
        key: CONSUMER_KEY,
        secret: CONSUMER_SECRET,
      },
      signature_method: 'HMAC-SHA1',
      hash_function: (baseString, key) =>
        crypto.createHmac('sha1', key).update(baseString).digest('base64'),
    });

    const request_data = {
      url: `${TWITTER_API}/oauth/access_token`,
      method: 'POST',
      data: {
        oauth_token: requestToken,
        oauth_verifier: oauthVerifier,
      },
    };

    try {
      const res = await Axios.post(
        request_data.url,
        null,
        { headers: { ...oauth.toHeader(oauth.authorize(request_data)) } },
      );
      const responseData = res.data;
      const authToken = responseData.match(/oauth_token=([^&]+)/)[1];
      const authTokenSecret = responseData.match(/oauth_token_secret=([^&]+)/)[1];

      Alert.alert(
        'Success',
        `authToken: ${authToken.slice(0, 7) + '...'}\nauthTokenSecret: ${
          authTokenSecret.slice(1, 7) + '...'
        }`,
      );
    } catch (error:any) {
      console.log('Error: access token', error.response?.data || error.message);
    }
  },
);

return () => subscribe.remove();

}, []);

return { signInWithTwitter, }; };

shuklaom84 commented 2 months ago

Error--------------

Task :react-native-quick-base64:configureCMakeDebug[arm64-v8a] C/C++: CMake Warning (dev) in CMakeLists.txt: C/C++: No project() command is present. The top-level CMakeLists.txt file must C/C++: contain a literal, direct call to the project() command. Add a line of C/C++: code such as C/C++: project(ProjectName) C/C++: near the top of the file, but after cmake_minimum_required(). C/C++: CMake is pretending there is a "project(Project)" command on the first C/C++: line. C/C++: This warning is for project developers. Use -Wno-dev to suppress it.

Task :app:mergeExtDexDebug Task :react-native-quick-base64:buildCMakeDebug[arm64-v8a] FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scri pts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings 79 actionable tasks: 74 executed, 5 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To rea d more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#d octor

FAILURE: Build failed with an exception.

BUILD FAILED in 56s info Run CLI with --verbose flag for more details.

Solution-----------

The error you encountered suggests several issues related to CMake configuration, Gradle deprecation warnings, and file deletion failure during the build process for the react-native-quick-base64 package in a React Native project. Let's break down the main issues and provide solutions:

  1. CMake Warning (dev) Issue: The warning indicates that your CMakeLists.txt file lacks a project() command, which should be defined near the top after the cmake_minimum_required() command. Solution: Add the project() command in your CMakeLists.txt. For example

code to add got to node_modules->react-native-quick-base64->android->CMakeLists.txt in this file add below mention line or add only project name i added only project name

cmake_minimum_required(VERSION 3.4.1) project(YourProjectName)


  1. Gradle Deprecation Warning Issue: Your build is using deprecated Gradle features, which may cause compatibility issues with Gradle 9.0 in the future.

Solution: Run the following command to view all deprecation warnings: bash Copy code ./gradlew build --warning-mode all Update the scripts or plugins as per the Gradle documentation or use plugins that are compatible with the latest Gradle versions. You can consult the Gradle documentation for more details. go to android folder and run below command

./gradlew build --warning-mode all

The error you encountered suggests several issues related to CMake configuration, Gradle deprecation warnings, and file deletion failure during the build process for the react-native-quick-base64 package in a React Native project. Let's break down the main issues and provide solutions:

  1. CMake Warning (dev) Issue: The warning indicates that your CMakeLists.txt file lacks a project() command, which should be defined near the top after the cmake_minimum_required() command.

Solution: Add the project() command in your CMakeLists.txt. For example: cmake Copy code cmake_minimum_required(VERSION 3.4.1) project(YourProjectName)

This will remove the warning about missing a project command.

  1. Gradle Deprecation Warning Issue: Your build is using deprecated Gradle features, which may cause compatibility issues with Gradle 9.0 in the future.

Solution: Run the following command to view all deprecation warnings: bash Copy code ./gradlew build --warning-mode all Update the scripts or plugins as per the Gradle documentation or use plugins that are compatible with the latest Gradle versions. You can consult the Gradle documentation for more details.

  1. Unable to Delete File Issue: The build is failing because a file cannot be deleted during the build process: D:\cbidz Twit rnd\txttest1\node_modules\react-native-quick-base64\android\build\intermediates\cxx\Debug\5h495514\obj\arm64-v8a Solution: Ensure no other processes (like antivirus or file sync services) are locking the file. Close any open IDEs (like Android Studio or VS Code) and try deleting the file manually.

You can also clean the build using: bash Copy code


commands need to run ./gradlew clean

After cleaning, attempt to rebuild: bash Copy code

./gradlew assembleDebug


  1. React Native Doctor It’s also recommended to ensure your environment is set up correctly. Run: bash Copy code

command -------------------------------- npx react-native doctor

may be you will face this issue

✓ Node.js - Required to execute JavaScript code ✖ yarn - Required to install NPM dependencies

Solution commands ------------------- install npm install -g yarn

final code

import Axios from 'axios'; import OAuth from 'oauth-1.0a'; import {useEffect} from 'react'; import {Alert, Linking} from 'react-native'; import Config from 'react-native-config'; import crypto from 'react-native-quick-crypto';

const CONSUMER_KEY = const CONSUMER_SECRET = const TWITTER_API = 'https://api.twitter.com'; const OAUTH_CALLBACK_URL = 'oauth-app://oauth'; // your app scheme

export const useSignInWithTwitter = () => { // request token const signInWithTwitter = async () => { const oauth = new OAuth({ consumer: { key: CONSUMER_KEY, secret: CONSUMER_SECRET, }, signature_method: 'HMAC-SHA1', hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64'), });

const request_data = {
  url: `${TWITTER_API}/oauth/request_token`,
  method: 'POST',
  data: { oauth_callback: OAUTH_CALLBACK_URL },
};

const headers = {
  ...oauth.toHeader(
    oauth.authorize({
      url: request_data.url,
      method: request_data.method,
      data: { oauth_callback: OAUTH_CALLBACK_URL },
    })
  ),
  'Content-Type': 'application/x-www-form-urlencoded',
  'Accept': 'application/json',
};

try {
  // Remove the empty {} body from the post request
  const res = await Axios.post(request_data.url, null, { headers });
  const responseData = res.data;
  const requestToken = responseData.match(/oauth_token=([^&]+)/)[1];

  // Redirect to Twitter login
  const twitterLoginURL = `${TWITTER_API}/oauth/authenticate?oauth_token=${requestToken}`;
  Linking.openURL(twitterLoginURL);
} catch (error) {
  console.log('Error in request token:', error.response?.data || error.message);
}

};

useEffect(() => { const subscribe = Linking.addEventListener( 'url', async (event: { url: string }) => { const url = event.url; const params = url.split('?')[1]; const tokenParts = params.split('&'); const requestToken = tokenParts[0].split('=')[1]; const oauthVerifier = tokenParts[1].split('=')[1];

    const oauth = new OAuth({
      consumer: {
        key: CONSUMER_KEY,
        secret: CONSUMER_SECRET,
      },
      signature_method: 'HMAC-SHA1',
      hash_function: (baseString, key) =>
        crypto.createHmac('sha1', key).update(baseString).digest('base64'),
    });

    const request_data = {
      url: `${TWITTER_API}/oauth/access_token`,
      method: 'POST',
      data: {
        oauth_token: requestToken,
        oauth_verifier: oauthVerifier,
      },
    };

    try {
      const res = await Axios.post(
        request_data.url,
        null,
        { headers: { ...oauth.toHeader(oauth.authorize(request_data)) } },
      );
      const responseData = res.data;
      const authToken = responseData.match(/oauth_token=([^&]+)/)[1];
      const authTokenSecret = responseData.match(/oauth_token_secret=([^&]+)/)[1];

      Alert.alert(
        'Success',
        `authToken: ${authToken.slice(0, 7) + '...'}\nauthTokenSecret: ${
          authTokenSecret.slice(1, 7) + '...'
        }`,
      );
    } catch (error) {
      console.log('Error: access token', error.response?.data || error.message);
    }
  },
);

return () => subscribe.remove();

}, []);

return { signInWithTwitter, }; };


shuklaom84 commented 2 months ago

{ "name": "login", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "axios": "^1.6.1", "oauth-1.0a": "^2.2.6", "react": "18.2.0", "react-native": "0.72.6", "react-native-config": "^1.5.1", "react-native-quick-base64": "^2.0.7", "react-native-quick-crypto": "^0.6.1" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.11", "@tsconfig/react-native": "^3.0.0", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "babel-plugin-module-resolver": "^5.0.0", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.76.8", "prettier": "^2.4.1", "react-test-renderer": "18.2.0", "typescript": "4.8.4" }, "engines": { "node": ">=16" } }

Dmitrylolo commented 1 month ago

did someone resolve this?